Home >Operation and Maintenance >Linux Operation and Maintenance >How to completely delete a user in linux
How to delete a user in Linux: First enter the system to create a user; then check some information directories for the user; finally delete the user correctly, the code is [[root@localhost /]# userdel -r haha].
The operating environment of this tutorial: linux5.9.8, DELL G3 computer.
How to delete a user in Linux:
1. First enter the system to create a user
[root@localhost /]# useradd haha #创建用户 haha是用户名 [root@localhost /]# passwd haha #为该用户设置密码
Change the password of user haha.
New password: ******
After the password setting is completed, it will prompt "passwd: All authentication tokens have been successfully updated.", indicating that the password has been set successfully.
2. Check some information directory of the user
3. Delete the user
If you use the userdel haha command to delete the user, It does not delete all the user's information, but only deletes the account and group information in the four files /etc/passwd, /etc/shadow, /etc/group/, and /etc/gshadow. By default, creating a user account will create a home directory and a user mailbox (named with the user name in the /var/spool/mail directory)
[root@localhost /]# userdel haha [root@localhost /]# cat /etc/passwd | grep haha [root@localhost /]# cat /etc/shadow | grep haha [root@localhost /]# cat /etc/group | grep haha [root@localhost /]# cat /etc/gshadow | grep haha [root@localhost /]# find / -name "*haha*"
See you next time When creating a user, an error will appear:
The above picture shows an error, so when you create the user account again, an error will be reported, which means that the files related to the user or The directory was not completely deleted before.
4. Delete the user correctly
[root@localhost /]# userdel -r haha
Then use the find command to check that the user-related files have been deleted.
##Related learning recommendations: linux video tutorial
The above is the detailed content of How to completely delete a user in linux. For more information, please follow other related articles on the PHP Chinese website!