How to Remove a User on Debian and Ubuntu Linux

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:

  1. Remove a user using GUI
  2. 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.

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Recent Posts

How to Install Magento 2 on AlmaLinux

Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…

1 year ago

How to Install ISPConfig Hosting Control Panel with Apache Web Server on Ubuntu 24.04

ISPConfig is an open-source control panel that allows users to manage multiple servers from a…

1 year ago

How to Test your Email Server (SMTP) Using the Telnet Command

As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…

1 year ago

Managing Network Interfaces and Settings on Ubuntu 24.04 with nmcli

Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…

2 years ago

Using Restic Backup on Ubuntu 24.04

Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…

2 years ago

Installing phpMyAdmin on Rocky Linux 9 and Securing it with Let’s Encrypt SSL

phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…

2 years ago