
How to Remove Users on Linux Mint 21?
In Linux, managing the users is one of the crucial activities performed by an administrator. While working in a network, multiple users have access to their concerned data. Adding or removing users is a frequently performed activity while managing users.
In this post, we will list the possible methods to remove users on Linux Mint 21 (the current latest LTS of Linux Mint).
Note: The above command will only remove the home directory if the mail spool is not found.
It will ask for authentication of the logged-in user. Enter the password to proceed further.
By clicking the user, you will see a delete option at the end, as highlighted below.
Confirm the selection by clicking on the “Yes” button, as shown below.
And here it is; the user has been deleted, which can be verified from the following image.
That’s how the users are deleted on Linux Mint 21.
How to Remove Users on Linux Mint 21 Using CLI?
Linux Mint is one of the leading distributions of Debian, which offers strong support to manage the system through commands. The “userdel” and the “deluser” commands are used to remove a user on Linux Mint. This section will show the practical demonstration of both methods.Remove Users Using the “userdel” Command
Before getting into the detailed working, the syntax of the “userdel” command is explained below.Syntax:
The “userdel” command removes the user from the system by following the syntax below.$ userdel <username>
If you want to delete the user alongside its home directory, use the syntax below.
$ userdel r <username>
Working:
What does the “userdel” command do? Let’s look at the following operations, which are carried out using the “userdel” command.- The user’s information is stored in the user files, i.e., “/etc/passwd” and “/etc/shadow”.
- The information carried by the group files of a user, i.e., “/etc/group” and “/etc/gshadow”.
Example: Remove the User Only
The command below will remove the user named genieuser with its files and the groups to which the user belongs.$ sudo userdel genieuser
Example: Remove Users With Home Directory
If you want to remove the user alongside its home directory, then use the “r” flag with its name, as the command below will remove the home directory and the mail spool of the user named genieeditor.$ sudo userdel -r genieeditor
Remove Users Using the “deluser” Command
The “deluser” also removes the user like “userdel”. However, they differ, which will be discussed in this section. Let’s have a look at the general syntax of the deluser command. Syntax:$ deluser <username>
While both commands have the same purpose, the deluser command has the more enriched and detailed support of the options described below.
- –remove-home: Deletes the home directory.
- –backup: Create a backup before deletion.
- –remove-all-files: It will delete all files owned by the user.
- –system: Deletes only the system user (if this option is used with the normal user, then the command will be unable to delete the user).
- –backup-to [directory]: Creates a backup to a specific directory before deleting the user.
Example: Remove the User
The below command will delete the user named “linuxuser” from the system.$ sudo deluser linuxuser
Example: Create a Backup and Then Remove Users
While deleting a user may cause unintended results, creating a backup before deleting is recommended. We have used the command provided below, which will create the backup, and then it will delete the user.$ sudo deluser --backup genieuser