monetization

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


Enjoyed that? Check These Posts Out

How to get the most out of our Project Management Software

Learn Linux: Environmental Variables Cheatsheet

Learn Linux: User Management with adduser, usermod and addgroup

Learning Linux: How To Find What Version Of Linux You're Running - Command uname and lsb_release

...
monetization

Article Comments

Let us know your thoughts below by adding a quick comment!

Leave A Comment