Linux Command Cheatsheet: User Management
Add a user to your system:
adduser <username>
Add a user to your system with a specific home directory
adduser --home <directory> <username>
Add a user to your system with a specific group:
adduser -g <groupname> <username>
Change a user's password
passwd <username>
Change a user's home directory
usermod -h <directory> <username>
Add a group to your system
addgroup <groupname>
Deleting a user
userdel <username>
Delete a user as well as their home directory
userdel -r <username>
Delete a group
groupdel <groupname>
Change a user's primary group
usermod -g <groupname> <username>
Add an existing user to an existing group as a secondary group:
usermod -a -G <groupname> <username>
To view a user's list of groups, GIDs and UID:
id <username>
To view a user's groups:
id -G -n <username>
A list of all users on the system can be found in the file:
/etc/passwd
A list of all groups on the system can be found in the file:
/etc/group
Leave A Comment