How to completely delete a user in linux

coldplay.xixi
Release: 2023-01-04 09:38:15
Original
17862 people have browsed it

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].

How to completely delete a user in linux

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   #为该用户设置密码
Copy after login

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

How to completely delete a user in linux

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

How to completely delete a user in linux

See you next time When creating a user, an error will appear:

How to completely delete a user in linux

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.

How to completely delete a user in linux

##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!

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!