Users & Groups

Create group

$ groupadd [name]
copy
$ addgroup [name]
copy

Delete group

$ groupdel [name]
copy

Rename group

$ groupmod -n [newGroupname] [oldGroupname]
copy

Create user

$ useradd [name]
copy
$ adduser [name]
copy

Delete user

$ userdel [name]
copy
$ deluser [name]
copy

Rename user

$ usermod -l [newUsername] [oldUsername]
copy

Set user password

$ passwd [name]
copy

Grant sudo privileges to an existing user

$ usermod -a -G sudo [user]
copy
$ adduser [user] sudo
copy

User information

$ finger [user]
copy

Add existing user to group

$ usermod -aG [groupName] [userName]
copy
$ adduser [userName] [groupName]
copy
$ gpasswd -a [userName] [groupName]
copy

Add new user to group

$ useradd -G [group] [user]
copy

Remove user from group

$ gpasswd -d [user] [group]
copy
$ deluser [user] [group]
copy

List all groups

$ getent group
copy
$ cat /etc/group
copy

List all users

$ getent passwd
copy
$ cat /etc/passwd
copy
Copied to clipboard
Binance