Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to delete system users by linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail how to delete users of the linux system. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

In linux, you can use the userdel command to delete users, which is used to delete data information related to the specified user with the syntax "userdel-r username"; the userdel command is available only to root users.

The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

The userdel command function is very simple, which is to delete the relevant data of the system user. This command is available only to root users.

The relevant data of the user includes the following items:

Basic user information: stored in / etc/passwd file

User password information: stored in / etc/shadow file

Basic user group information: stored in / etc/group file

User group information information: stored in / etc/gshadow file

User personal files: the home directory is located at / home/ user name by default, and the mailbox is located at / var/spool/mail/ user name.

In fact, the function of the userdel command is to delete the data information related to the specified user from the above file.

The syntax of the userdel command is simple, and the basic format is as follows:

[root@localhost ~] # userdel-r user name

The-r option means that the user's home directory is deleted while the user is deleted.

Note that if you delete the user's home directory without deleting the user's home directory, the home directory will become a directory without owners and groups, that is, junk files.

For example, to delete a lamp user, simply execute the following command:

[root@localhost] # userdel-r lamp

In addition to using the userdel command to delete the user, you can also delete it manually. After all, from the previous study, we already know where the information related to the user is stored. Although this is of no practical significance, it can deepen your understanding of the userdel command for beginners.

The specific actions to delete the specified user manually are as follows:

# create a new lamp user [root@localhost ~] # useradd lamp [root@localhost ~] # passwdlamp # set the password for the lamp user, so that the lamp user is created successfully # start manually deleting lamp [root@localhost ~] # vi / etc/passwdlamp:x:501:501::/home/lamp:/bin/bash

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report