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
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
newadded user entry goes in /etc/ passwdfile and to check the newly added user, view the output of /etc/passwd/ file.
[root@localhost ~]# cat /etc/passwd
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/
[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
- Now we are going to completely remove user along with user’s home directory data, use the
[root@localhost centos]# userdel -r centos
- /etc/passwd/: keep records of all the added users. We can check registered users from this path.
- /home: User’s home directory path by default.
Perfect!! You have learned how to add and delete a user.