Create and remove CentOS users

In this article, we will show you how to create and remove CentOS users/accounts. We will not create/delete cPanel accounts here!

You must be logged in as root to be able to create new accounts.

There can be situations when you want to create users on your CentOS server. To create a new user, use the command:

adduser username

After this, set the password for the new user, so he/she can log in:

passwd username

You can also check the default values for the adduser command with the -D argument:

root@web [~]# adduser -D
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes

Example for creating a CentOS user and setting a password for it:

root@web [~]# adduser tonyw
root@web [~]# passwd tonyw
Changing password for user tonyw.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
root@web [~]#
root@web [~]# cd /home/tonyw
root@web [/home/tonyw]# ls
./  ../  .bash_logout  .bash_profile  .bashrc  .zshrc
root@web [/home/tonyw]#

To remove a CentOS account, use:

userdel -r username

The -r argument will remove the user’s directory.

centos logo
CentOS Logo

Leave a Reply