[Ubuntu] User Management

less than 1 minute read

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

Add group

$ sudo groupadd --gid 2000 cglab

Add user

$ sudo useradd [username] -m
$ sudo passwd [username]
$ sudo usermod -a -G docker [username]

Note
-m: Create home directory.
-a: Add the user to the supplementary group(s).
-G: A list of supplementary groups which the user is also a member of.

Add sudo group

We are giving root privilege for those of who are in the group cglab.

$ sudo visudo

Add following line:

...
cglab ALL=(ALL) ALL
$ sudo usermod -a -G cglab [username]

in user account, type:

$ sudo usermod -g cglab [username]

Note
-g: The group name or number of the user’s new initial login group.


(Optional) Change shell to zsh

Note
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)"

$ sudo vim /etc/passwd

add following end of line where [username] is:

...
/bin/zsh

Leave a Comment