How to delete a user in linux

藏色散人
Release: 2020-10-14 17:21:40
Original
15317 people have browsed it

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.

How to delete a user in linux

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*"
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!