Home >Operation and Maintenance >Linux Operation and Maintenance >How to delete a user in linux
How to delete a user in Linux: First enter the command window; then enter and execute the command "[root@localhost /]# userdel -r haha" to delete the user.
Recommended: "linux tutorial"
1. First enter the system to create a user
[root@localhost /]# useradd haha #Create user haha is the user name
[root@localhost /]# passwd haha #Set a password for the user
Change user haha password.
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.
The above is the detailed content of How to delete a user in linux. For more information, please follow other related articles on the PHP Chinese website!