How to completely delete user accounts under Linux

Source: Internet
Author: User

How to completely delete user accounts under Linux


Experimental background:

(1) Virtual machine software: VMware Workstation 12;

(2) Operating system: Centos6.7 32-bit

Experimental steps:

(1) After entering the system, we first create a user account.

[[email protected] ~]# useradd www #创建用户, name is www

[Email protected] ~]# Ls/home #查看刚创建的用户账户

[Email protected] ~]# cat/etc/passwd |grep www

Www:x:501:501::/home/www:/bin/bash

[Email protected] ~]# Cat/etc/shadow |grep www

Www:!! : 17294:0:99999:7:::

[Email protected] ~]# Cat/etc/group |grep www

www:x:501:

[Email protected] ~]# Cat/etc/gshadow |grep www

Www:!::

As follows:

650) this.width=650; "src=" https://s3.51cto.com/wyfs02/M00/94/FF/wKiom1kQe2qSBRLaAAA5DiqjKZg222.png "title=" www. PNG "alt=" Wkiom1kqe2qsbrlaaaa5diqjkzg222.png "/>

(2) Delete User www, if we use Userdel www directly, then can not delete all relevant information of the user account, just delete/etc/passwd,/etc/shadow,/etc/group/,/etc/ Gshadow the account and group information in four files. Because a user account is created by default, a home directory and a user mailbox are created (in the/var/spool/mail directory named after the user name). We can use the Find command to find all the file information associated with that user "Find/-name" *www* "".

The command is as follows:

[Email protected] ~]# Userdel www

[Email protected] ~]# cat/etc/passwd |grep www

[Email protected] ~]# Cat/etc/shadow |grep www

[Email protected] ~]# Cat/etc/group |grep www

[Email protected] ~]# Cat/etc/gshadow |grep www

[[email protected] ~]# Find/-name "*www*"

As follows:

650) this.width=650; "src=" https://s4.51cto.com/wyfs02/M00/94/FF/wKioL1kQfbSD-r3TAAAjQxbGBiI021.png "title=" www. PNG "alt=" Wkiol1kqfbsd-r3taaajqxbgbii021.png "/>

(3) We now create the WWW account again

650) this.width=650; "src=" https://s1.51cto.com/wyfs02/M01/94/FF/wKioL1kQfrbAcwd7AAATzxGpvzI509.png "title=" www. PNG "alt=" Wkiol1kqfrbacwd7aaatzxgpvzi509.png "/>

Show Error! So when you create the user account again, you will get an error, which means that the files or directories associated with that user are not completely deleted.

(4) Correct deletion of accounts

[Email protected] ~]# Userdel-r www

As follows:

650) this.width=650; "src=" https://s5.51cto.com/wyfs02/M00/94/FF/wKioL1kQf3ux6uuyAAAfb0XAHUo922.png "title=" www. PNG "alt=" Wkiol1kqf3ux6uuyaaafb0xahuo922.png "/>

We see that when you delete an account with the Userdel-r command, you use the Find command to see that the user www-related files have been deleted. So we use Useradd www command again to create the user www, the system did not error!

This article is from the "Hand of the Paladin Control" blog, please make sure to keep this source http://wutengfei.blog.51cto.com/10942117/1923446

How to completely delete user accounts under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.