Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Assign new users to two groups?

    Is it possible in Linux to assign a new user who log in for the first time to two different groups?
    The situation is: Im a computer trainee at the geological institution in Lund Sweden, I have set up ubuntu as a Macintosh Time Machine backup server. The server is set up to accept both local users and LDAP users, and when I log in from the Mac with a user in LDAP but who's not in the local users list, ubuntu creates a new home directory at /home/<username>, with the help of PAM mk_homedir.

    The problem is : I have made a separate folder /Backup, where I mount the Time Machine disk. I have created a new group called tmusers, and I want only the members of this group to be able to access and write to the /Backup folder
    My supervisor wants the process of creating a user to be as transparent as possible (i.e. it saves him time to do other things). The best situation would be not needing to do anything on the server at all.
    So I need the users to be member of their own group AND "tmusers" . Furthermore the adding of a specific user to "tmusers" should be done only the first time a user logs in, wether its a local user or a LDAP user.

    Does anyone know how to solve whole/parts of this problem? Any help greatly appreciated.

    best regards

  2. #2
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Harrow, UK
    A user can belong to as many groups as you like. Just use the usermod command to add the user to the new group (usermod -aG groupname username).
    "I'm just a little old lady; don't try to dazzle me with jargon!"

  3. #3
    Linux User Krendoshazin's Avatar
    Join Date
    Feb 2005
    London, England
    How is the user login being created in the first place? If it were me I would just add the additional groups when the user login is created, such as `useradd -m -G backup testuser`; if you need the additional group for every single user you add, then you could create an alias with `alias useradd='useradd -m -G backup'` - this way you can simply type `useradd testuser`.
    bash-4.0# groups testuser
    testuser : testuser backup
    /etc/default/useradd allows you to set default values for creating new users:
    # useradd defaults file
    By specifying HOME as /home, using the -m flag automatically creates a home directory as HOME/LOGIN, and the SKEL directory contains all the files you want in there by default.

  4. $spacer_open
  5. #4
    Hi & thankyou for your answers to this thread! My appologies, I
    think I havent been clear enough about what the problem is really
    about. The problem is :

    I need LDAP users to automatically be assigned to the group tmusers
    when they login for the first time from a mac.
    It goes like:
    1. A user wants to use Time Machine to backup his data. He/she has not done it before.
    2. He/she enters the username and passwd and logs in
    for the first on the ubuntu server with an LDAP account.
    3. The ubuntu server creates a new homefolder for the user automatically
    4. The new user should be assigned to a specific group, tmusers, in addition
    to the original group.
    Is there a way to do the last step automatically so that I dont have to touch
    the ubuntu server at all ( i.e. not usermod etc.) ?

    I doŽnt think it is possible myself.....any ideas?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts