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

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
Note: The above command will only remove the home directory if the mail spool is not found.

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

How to Remove Users on Linux Mint 21 Using GUI?

This section carries out the GUI of the Linux Mint 21 to remove users. The steps are performed in the “Cinnamon” environment. However, they are the same for “MATE” and “Xfce”.

Step 1: Open User and Groups

Click on the Mint icon on the start bar and search for the user, and you will get the “user and groups” in the result, as shown below. Click on the option.  It will ask for authentication of the logged-in user. Enter the password to proceed further.

Step 2: Choose and Delete the User

A user list will appear, where you must choose the user you want to delete. 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.

Conclusion 

While working collaboratively, when a user leaves the system/network, the administrator has to delete its files and the account information. To do so in Linux Mint, two commands, i.e., “deluser” and “userdel”, are utilized. Other than these, a GUI method can also be carried out. The GUI method’s working is almost the same around all the desktop environments of the Linux Mint.  All the above-stated methods are practically described in this post.
Print Friendly, PDF & Email