How to delete a user on Ubuntu

Ubuntu is a Linux operating system based on the Debian distribution. It currently defaults to the Unity desktop environment (DE), although previous versions of Ubuntu used the Gnome DE. Ubuntu primarily consists of open-source software that's distributed under the GNU General Public License at no charge. As with all other operating systems, maintaining user accounts is a routine task for Ubuntu system administrators. The essential steps for removing a user in Ubuntu include deleting the account and then deleting that user's home directory.
DIFFICULTY Basic - 1 | Medium - 2 | Advanced - 3
RELATED PRODUCTS Linux-based VPS or dedicated servers

Here is a quick tutorial on how to delete a user on Ubuntu.

Remove the user's account

Open a terminal window and enter the following command:

# sudo userdel testuser

The above line uses the userdel command to remove the account for testuser. The use of sudo ensures that this command has the required superuser privileges.

Delete the user's home directory

Enter the following command to delete the user's home directory:

# sudo rm -rf /home/testuser

This command removes the directory with the rm command. The r option removes the directory recursively, meaning that the subdirectories of /home/testuser are also removed. The f option forces the command, meaning that it will assume default responses without prompting you.

Verify the user account has been deleted

su testuser

You should receive an error saying this user does not exist

Was This Article Helpful?
Thank You For Your Feedback
Glad we helped! Anything more we can do for you?
Sorry about that. How can we be more helpful?