How to Add and Delete Users on CentOS 7

You may need to create separate account for every user want to connect this system. For adding new users in system there are two commands available in your system, useradd and adduser. adduser command is the enhanced version of useradd command. adduser command uses useradd command in backend. Knowing how to add and remove users is one of the most essential skills each Linux user should know.
This tutorial will help you to add and delete user on CentOS, RHEL, Fedora and CoreOS operating systems.


You need to be logged in as root or user with sudo privileges to create and remove users.

How To Add User in CentOS

For this tutorial we are using adduser command for examples. Following command will create new user named ‘aleandro’ on your system:

sudo adduser aleandro

The command above displays no output. It will create the new user’s home directory (/home/aleandro), and copy files from /etc/skel directory to the user’s home directory. Within the home directory, the user can write, edit, and delete files and directories.

Advanced Options

If you like to set a different home directory, use the --home option. e.g.:

adduser --home /home/otherdirectory aleandro

The new shell user will use the CentOS default shell. To specify a different shell like /bin/sh, use the option --shell followd by the path to the shell binary. combined with our different home path from above, the command will look like this:

adduser --shell /bin/sh --home /home/otherdirectory aleandro

The adduser command is the first step in the process of adding a new user on CentOS. This needs to be followed up by assigning a new password to the user, and typing and confirming the new password upon receiving the system prompt. Administrators need to use the following command for that:

passwd aleandro

You will be prompted to enter and confirm the password. Make sure you use a strong password.

Changing password for user aleandro.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

By default on CentOS, members of the group wheel are granted with sudo access.
If you want the newly created user to have administrative rights, add the user to the wheel group:

usermod -aG wheel aleandro

A list of all options is available in the manpage of the command. The manpage can be shown with this command:

man adduser

To quit the manpage, press “q“.

How To Delete a User in CentOS

If the user account is no longer needed, you can delete it using the deluser command line tool.
To delete the user, without deleting the user files, run:

userdel username

If you want to delete and the user’s home directory and mail spool use the -r flag:

userdel -r username

On success the userdel command doesn’t produce any output.
If the user was granted sudo privileges it will be removed the wheel group, as well as from any other groups the user was a member of.


In this tutorial, you learned how to add and remove users in CentOS. The same commands apply for any other Linux distribution.
If you have any question or feedback feel free to leave a comment.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button