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
(Visited 49 times, 1 visits today)
By | 2016-07-05T12:59:50+00:00 June 19th, 2016|Cheatsheet, Linux, Tutorials|0 Comments

Leave A Comment

Show Buttons
Hide Buttons