Home Linux CentOS How to Add and Delete Users on CentOS 7

How to Add and Delete Users on CentOS 7

In the previous tutorial, I have explained how to set date and time. Now you will learn how to add and delete users on CentOS 7 and will also learn where adduser command creates entries in filesystems.

Add a New User

  • To add a new user, use command adduser, here I am adding user “centos” & also assigning the password.
 [root@localhost ~]# adduser centos
[root@localhost ~]# passwd centos
adduser command
adduser command
  • Every new added user entry goes in /etc/passwd file and to check the newly added user, view the output of /etc/passwd/ file.
[root@localhost ~]# cat /etc/passwd
passwd file output
passwd file output

How to Delete a User

Use the below command to delete a user. Now, user centos would not be found, as we can check it using cat /etc/passwd. It will only delete the user name from /etc/passwd, but users data will remain in the system.

[root@localhost centos]# userdel centos
 [root@localhost centos]# cat /etc/passwd
  • If we go to deleted user home directory, then we can find all centos user data
user home directory
user home diretory
  • Now we are going to completely remove user along with user’s home directory data, use the following command.
 [root@localhost centos]# userdel -r centos 
userdel command centos
userdel command centos


  1. /etc/passwd/: keep records of all the added users. We can check registered users from this path.
  2. /home: User’s home directory path by default.

Perfect!! You have learned how to add and delete a user.


Please enter your comment!
Please enter your name here