This post describes a multi-user management method that I use in the lab. Since all the users require a root privilege, it is better to have only one group with the root privilege.

Adding group and user

  • Add a group (if the group does not exist.)
    $ sudo groupadd --gid 2000 cglab
    

Giving sudo privilege to a group

  • Add a sudo group for allowing the root privilege for those who are in the group cglab.
    $ sudo visudo
      
    # add the following line:
    cglab ALL=(ALL) ALL
    
  • Add a user and assign the user to group(s).
    $ sudo useradd USER_NAME -m
    $ sudo passwd USER_NAME
    $ sudo usermod -aG cglab,docker USER_NAME
    
    • Tip.
      • -m: Create a home directory.
      • -a: Add a user to the supplementary group(s).
      • -G: A list of supplementary groups in which the user is associated.
  • In the user account, type the following to set the primary group:
    $ sudo usermod -g cglab USER_NAME
    

    Tip. -g: sets a primary group


  • Note: Adding a user to groups
    • If you are running an NIS server, add the user to groups in the master server, as well as the client server. e.g.,:
      # using the new user account in the client server,
      $ sudo usermod -aG cglab,docker USER_NAME
      
  • Note: Changing shell
    • Make sure to install zsh and oh-my-zsh first
      $ sudo apt-get install zsh
      $ sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
      
    • If you are running an NIS server, the following code should be done in the master or slave server. Otherwise, do this in the local server:
      $ sudo vim /etc/passwd
      
      # add following at the end of the line where USER_NAME is:
      /bin/zsh
      

Leave a comment