User management is an important part of Linux administration. Sometimes you need to list the users on a system or disable a user account. Other times, you may need to delete a user account entirely, which is what we’ll be covering in this guide.
There are a couple of methods for deleting user accounts on a Linux system. One way to do it is via the command line, and the other method is via GUI, which varies depending on the desktop environment you’re running. We’ll be covering the command line method as well as removing a user in GNOME and KDE.
In this tutorial you will learn:
- How to remove a user via command line
- How to remove a user on GNOME GUI
- How to remove a user on KDE GUI
Category | Requirements, Conventions or Software Version Used |
---|---|
System | Any Linux distro |
Software | N/A |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions |
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
Remove a user via command line
To delete a user via the command line, open a terminal and execute the following command:
# userdel username
To remove the user’s home directory at the same time, add the -r
option:
# userdel -r username
The 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.
# killall -u username OR # userdel -f username
The user should now be eradicated from the system after successful exection of the userdel
command.
Remove a user on GNOME GUI
To remove users in GNOME, you’ll need to install the gnome-system-tools
package. You can install it by typing the following command in terminal if you’re running Ubuntu or another Debian based distro:
$ sudo apt install gnome-system-tools
Arch Linux and Manjaro:
$ sudo pacman -S gnome-system-tools
$ sudo dnf install gnome-system-tools
Once it’s installed, you’ll be able to open the Users & Groups application.
From here, just highlight the user you wish to delete and click the 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.
Conclusion
In this guide, we learned how to delete users on Linux from the command line and GUI. This includes GNOME and KDE, two of the most popular desktop environments. All methods are equally viable, so you should pick whichever is easiest for you.