Accounts (Users and Groups)

Updated: 2020-06-29

Get Info

Assuming my user account is ubuntu

$ whoami
ubuntu

Or check $USER

$ echo $USER
ubuntu

List the IDs:

$ id ubuntu
uid=1000(ubuntu) gid=1000(ubuntu) groups=1000(ubuntu),4(adm),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),109(netdev),110(lxd),999(docker)

Get UID:

$ id -u
1000

Get the read-only, effective user ID

$ echo $EUID
1000

List the groups:

$ groups ubuntu
ubuntu : ubuntu adm dialout cdrom floppy sudo audio dip video plugdev netdev lxd docker

Manage Users and Groups

groupadd: add a new group

$ sudo groupadd docker

usermod: modify user, e.g. add user to group docker

$ sudo usermod -aG docker $USER