How to delete user on Ubuntu

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)
How to delete a user on Ubuntu

How to delete a user on Ubuntu

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Ubuntu Linux
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

NOTE
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 sudo -i command.

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 -r option.

$ sudo 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.

$ sudo killall -u username
OR
$ sudo userdel -f username

The user should now be eradicated from the system after successful execution of the userdel command.

Remove a user on GNOME GUI

  1. To remove users in GNOME on Ubuntu, you’ll need to install the gnome-system-tools package. 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
    
  2. Once it’s installed, you’ll be able to open the ‘Users & Groups’ panel from the applications launcher.
  3. Open the Users and Groups application

    Open the Users and Groups application

  4. From here, just highlight the user you wish to remove and click the delete button to remove it.
  5. Highlight the user and click the delete button

    Highlight the user and click the delete button



Remove a user on KDE GUI

  1. KDE has a built in user management menu. You can simply search for it in the app launcher.
  2. Open the User Manager application

    Open the User Manager application

  3. Highlight the user you wish to delete and click on the minus sign button to remove it.
  4. Click the minus button to delete a user

    Click the minus button to delete a user

Conclusion

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.