How to Delete User Accounts in Ubuntu

This brief tutorial shows students and new users how to delete user accounts in Ubuntu 20.04 | 18.04.

In some cases you may need to delete a user account in Ubuntu. For example, if you created a standard user account for someone who no longer needs access to the systems, you can follow the steps below to delete his/her account.

For security reasons, it’s a good idea to delete unused accounts on Ubuntu or any other systems.

Keeping old and unnecessary accounts on Linux machine may introduce security risks. So regular go through the user list and make sure accounts that should be active are deleted or at least disabled.

To get started with deleting user accounts in Ubuntu, follow the steps below:

Delete user accounts

To quickly delete a user account, simply open the terminal. To do that, press Ctrl - Alt - T on your keyboard.

When the terminal opens, run the commands below to delete the account.

sudo deluser --remove-home accountNameHere

Replace accountNameHere with the account name you wish to delete.

Backup and delete user accounts

If you wish to backup the user account before deleting, you will have to create a backup directory to store the user content into.

First, create a backup directory for users files.

sudo mkdir /UsersBackups
sudo chown root /UsersBackups
sudo chmod 0700 /UsersBackups

After creating the backup location above, run the delete command with the backup option:

sudo deluser --remove-home --backup-to /UsersBackups/ accountNameHere

That will save a backup copy of the user’s home folder and delete the account.


To verify that the account was deleted, run the commands below:

id accountNameHere
grep '^accountNameHere' /etc/passwd

If the accounts were successfully deleted, those commands should return no accounts information.

The deluser command has its default configuration file at /etc/deluser.conf.

The file contains default options for the deluser command. If you want to change its default configuration values, open the file and change the values that should be executed when the command is run.

Details of the file:

cat /etc/deluser.conf

The content of the file:

# Remove home directory and mail spool when user is removed

# Remove all files on the system owned by the user to be removed

# Backup files before removing them. This options has only an effect if

# target directory for the backup file

# delete a group even there are still users in this group

# exclude these filesystem types when searching for files of a user to backup
EXCLUDE_FSTYPES = "(proc|sysfs|usbfs|devpts|tmpfs|afs)"

That’s it!


This post showed you how to delete user accounts on Ubuntu. If you find any error above, please use the comment section to report.

You may also like the post below:

How to Always start Edge in InPrivate Browsing Mode – Website for Students

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.