When using Debian or Ubuntu operating system on your server or desktop, you sooner or later will have to add or remove users from your system. This article will guide you on how to remove a user from the Debian or Ubuntu Linux distribution using the graphical user interface as well as through the Terminal. So, let’s go into the details.
Using the two different ways you can remove a user from Linux:
- Remove a user using GUI
- Remove a user using the Terminal
Prerequsites
- Debian or Ubuntu system Desktop or Server.
- This has been tested with Ubuntu 20.04 and Ubuntu 22.04 and Debian 10 and Debian 11. the same steps should work in newer versions too, we will test the steps on a regular basis and keep this guide updated.
Remove user using GUI
To remove a user using the graphical interface, click on the down arrow sign which is located at the top right corner of your desktop, and then click on the setting icon from the displaying drop-down list.
Now, from the displaying window, click on the search icon that is highlighted red in the following screenshot and type the ‘Users’ keyword in the given search bar.
Click on the ‘Users’ icon that is displayed in the search result.
Now, you need to unlock the current login account. For this purpose, click on the ‘Unlock’ button as shown in the following screenshot.
It will ask you to enter the account password for authentication. Enter the login account password and click on ‘Authenticate’.
Note: Only a sudo user or administrator can remove a user from your system. So, it is assumed that you are currently login from your administrator account.
Select the user that you want to remove from your Debian or Ubuntu system and click on the ‘Remove User’ which is highlighted in the following image:
As you click on the ‘Remove User’, the following prompt will display on the system that will ask you whether you want to delete all associated files or want to keep them. Click on the ‘Delete Files’. It will delete the user with all its associated files from your system.
Now, you will see that the selected user has been removed from your Linux system.
Remove a user using the Terminal
Linux users who prefer to use the Terminal to perform each task can also remove the user using the Terminal. For that purpose, you need to open the Terminal application on your system. Click on ‘Activities’ and search Terminal with the help of the application search bar as follows:
Click on the Terminal. You will see the following Terminal screen on your system. Now, you can run commands on it.
To delete a user run the following command on the Terminal:
$ sudo deluser user-name
Replace the user name with the user that you want to remove. Here, we are removing a user ‘sam’ from the system.
$ sudo deluser sam
Delete the user along with its home directory
You can also remove the user along with the user’s directory from your system by using the following command:
$ sudo deluser --remove-home user-name
For example, if you want to remove user ‘sam’ along with the directory, then the above command will be changed in the following command:
$ sudo deluser --remove-home sam
To remove a user with all its associated files from your system, use the following command:
$ sudo deluser --remove-all-files user-name
Replace the user name with the user that you want to delete along with all associated files.
that’s it, you successfully removed an account from your Debian or Ubuntu system.