As a Linux system administrator, you need to manage the system user accounts regularly, and delete unnecessary users in time to avoid unnecessary trouble. To delete user accounts, you need to use the userdel command. Xiaobian will introduce you to Linux using the userdel command to delete users.
userdel what
userdel is a low-level tool for deleting users. On Debian, we usually use the deluser command. Userdel queries system account files such as /etc/password and /etc/group. Then it will delete all entries related to the username. The username must exist before we delete it.
How to use userdel
Since userdel will modify the system account file, we need root privileges to run it. Otherwise we will encounter an error message <; only root privileges can perform this operation & rdquo; or similar information. After we get the privilege, we can remove the user from your console by typing userdel. Below is an example of using userdel by default.
$ sudo userdel pasadena
or
# userdel pasadena
As you can see, we can not do without root privileges and delete user pasadena. When we have permission, the system does not give an error message, which means that the user has successfully deleted.
Completely delete user home directory
Without user option, only user will be deleted. The user's home directory will still be in the /home directory.
As we enter the /home directory, we can still see ID 1002 has pasadena folder. A created user will usually have a group name that is the same as the username. 1002 is the UID of the pasadena username and the GID of the pasadena group name.
In order to completely delete the home directory when deleting users, we can use the -r option. This option will also delete the user's mail pool, if it exists.
forcibly remove a user
userdel provides -f option to force the removal of the user. This option still works even when the user has logged into the Linux system. Take a look at the sample screenshot. The above
pasadena screenshot displays the user has logged into the system. The process 6218 it is tagged is the SSHD process. And when we use “userdel -f pasadena”, only the user information that has been logged in to be deleted will be displayed. The command itself has been successful. If we use the cat command to view the contents of /etc/passwd, we can't see the user pasadena. His home directory still exists but the owner can only display it as a numeric ID.
One thing we must understand is that the userdel with the -f option does not disconnect the existing SSH link for that user. Therefore, even if the user does not already exist, it is actually a login state and is an active user. However, you cannot log in again after the user logs out because the user has been deleted.
So this option is dangerous to use because it puts your system into an inconsistent state.
Summary
The above is a description of how Linux uses the userdel command to delete a user account. The userdel command can be used not only to delete system user accounts, but also to delete files.
In the Uuntu system, many users have set the account name and password, but some users can easily fo
We all know that the rm command in Linux can be used to delete files, and the delet
On Linux systems, if SSH does not work for a long time, the request timeout will be automatically di
The Fedora 22 version was released in May of this year. A lot of new features have
Linux beginners need to understand the Bash command operation skills to share
RedHat/CentOS 7 Steps to Manage the Network Through the nmcli Command
What are the commands for monitoring the performance of Linux systems?
Linux recovery method was mistakenly deleted root user
How Linux uses ssh to transfer files to FTP space
Linux system how to configure rdate time server
How to use the Linux system Passwd command
How to solve the problem of cant find libjava.so under Ubuntu?
Ubuntu installs Pacman package manager step
How to configure the IP and host name of the CentOS7 system
Windows xp system installation steps diagram
Enterprise User Windows 7 Deployment Raiders Automated Installation
What should I do if the Win8 input method icon is missing?
How to access the disk space of Win8.1 Update with one click?
Win10 game compatibility super WinXP officially released on July 29th
Novice tutorial: boot failure solution for hard disk failure
Win10 Mobile Build 14322 has been fixed and known issues
Win10 Mobile/PC build 10586.589 exposure: The old model has a share of
How to solve the problem that there is Win8 Key but can't upgrade the system