How to add and remove users on CentOS 8

One of the first tasks in preparing a new Linux server is adding and removing users. Each user can have different permission levels and specific settings for different command line and GUI applications.

This article explains how to add and remove users on CentOS 8 systems.


To be able to create and delete users, you need to be logged in as root or a user with sudo privileges.

How to add a user on CentOS 8

On CentOS, you can create a new user account with the useradd command followed by the username you want to create.

For example, to create a new user account named “andreyex”, you would run:

sudo adduser andreyex

If successful, the team does not produce any results. It creates the user and user’s home directory (/ home / andreyex) and copies files from the / etc / skel directory to the user’s home directory. In the home directory, the user can write, edit and delete files and directories.

If you are logged in as root, you do not need to add sudo to every command.

Then you need to set a password for the new user so that the user can login. To do this, issue the passwd command followed by the username:

sudo passwd andreyex

You will be prompted to enter and confirm your password:

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

Make sure you use a strong password that contains upper and lower case letters, numbers, and special characters.

Granting sudo privileges

By default, on CentOS, wheel members are granted sudo access.

If you want the newly created user to have administrator rights, add it to the group:

sudo usermod -aG wheel andreyex

You can also configure sudo user access by modifying the sudoers file.

How to delete a user on CentOS

To remove a user account no longer needs to be done, issue the userdel command followed by the username.

For example, to delete a user account named “andreyex”, you would run:

sudo userdel andreyex

If successful, the team does not produce any results.

The above command will delete the user without deleting the user files. The user is also removed from any group to which he belonged.

To remove a user and remove their home directory and mail folder, pass the -r userdel parameter:

sudo userdel -r andreyex


We showed you how to add and remove users on CentOS 8. The same commands apply for any other Linux distribution.

CentOS, like all other Linux distributions, is a multi-user operating system. Knowing how to add and remove users is one of the basic skills that every Linux user should know.

Feel free to leave comments if you have any questions.