How to completely delete a user under linux

Reprinted: http://blog.51cto.com/wutengfei/1923446

1. First enter the system to create a user

[root@localhost /]# useradd haha ​​#Create user haha ​​is the username

[root@localhost /]# passwd haha ​​#Set the password for this user

Change the password for user haha.
New password: *****

After the password is set, it will prompt "passwd: All authentication tokens have been successfully updated.", indicating that the password has been set successfully.

2. View some information directories of the user

3. Delete user

If the userdel haha ​​command is used to delete the user, it does not delete all the information of the user, but only deletes the account and group information. By default, a user account is created, which will create a home directory and a user mailbox (named after 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*”

The next time the user is created, it will appear:

The above picture reports an error, so when you create the user account again, an error will be reported, which means that the files or directories related to the user have not been completely deleted before.

4. Correctly delete users

[root@localhost /]# userdel -r haha

Then use the find command to check that the user-related files have been deleted.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324145964&siteId=291194637