Managing user accounts on Ubuntu Linux may involve listing the users on a system, creating a new user, or disabling a user account. Other times, you may need to delete a user account entirely, which is what we'll be covering in this guide.
It's possible to delete a user account from an Ubuntu system via either command line or GUI. The command line method will work on any system, but the GUI method will vary slightly, depending on the desktop environment you're using. In this guide, we'll be showing the process for command line, GNOME, and KDE. This should cover most installations, since GNOME is the default GUI for Ubuntu and KDE the default for Kubuntu. Let's get started.In this tutorial you will learn:
- How to remove a user via command line on Ubuntu
- How to remove a user on GNOME GUI (default Ubuntu desktop)
- How to remove a user on KDE GUI (default Kubuntu desktop)
|Category||Requirements, Conventions or Software Version Used|
|Other||Privileged access to your Linux system as root or via the |
|Conventions|| # - requires given linux commands to be executed with root privileges either directly as a root user or by use of |
Remove a user via command line
Deleting or modifying user accounts on Ubuntu will always require root permissions. Be sure to preface these commands with
sudo, or elevate to the root account with the
To delete a user via the command line, open a terminal and execute the following command. Be sure to replace 'username' with the actual name of the user you wish to delete.
$ sudo userdel username
To remove the user's home directory at the same time, add the
$ sudo userdel -r username
userdel command won't work if the user is currently logged in or has processes running under the account. In this case, you have two options. You can either kill all the user's processes with the
killall command or use the
-f option with the
userdel command to force deletion.
$ sudo killall -u username OR $ sudo userdel -f username
The user should now be eradicated from the system after successful execution of the
Remove a user on GNOME GUI
- To remove users in GNOME on Ubuntu, you'll need to install the
gnome-system-toolspackage. Open a terminal and type the following commands to install the package via apt package manager.
$ sudo apt update $ sudo apt install gnome-system-tools
- Once it's installed, you'll be able to open the 'Users & Groups' panel from the applications launcher.
- From here, just highlight the user you wish to remove and click the delete button to remove it.
Remove a user on KDE GUI
- KDE has a built in user management menu. You can simply search for it in the app launcher.
- Highlight the user you wish to delete and click on the minus sign button to remove it.
In this guide, we learned how to delete users on Ubuntu from the command line and GUI. This includes GNOME, which is the default desktop environment, and KDE, which is the default desktop environment for Kubuntu. All methods are equally viable, so you should pick whichever is most convenient for you.