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

Learn Linux: Setup DNS Server with Bind On Debian

Pro Login User Management System - PHP

Pro Login Content - CMS Secure User Management System

Learn Linux: How to Install and configure ftp with proftpd

...

Article Comments

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

Leave A Comment