Learn how to Delete User Accounts in Ubuntu

How to Delete User Accounts in Ubuntu

This post shows that how to Delete User Accounts in Ubuntu. If you want to Delete User Accounts in Ubuntu then this post is ideal for you.

If you wish to delete unused and unnecessary accounts in your Ubuntu system then you can follow the below steps to delete account.

To delete unused and unnecessary accounts is a good idea because Keeping unused and unnecessary accounts on Linux system may occur serious security risks.

Ubuntu is a Linux Operating System based on Debian and mostly composed of non-profit(free) and open-source software. It is a complete Linux operating system that compatible with desktops, laptops, server and other devices. Ubuntu is Open Source so it is freely available for both community and professional support.

If you are a learner and looking for a Linux distribution for Learning then Ubuntu Linux Operating System is best for you as a beginning.

Please follow below steps to Delete User Accounts in Ubuntu :


How to Delete user accounts

To a user account, open the terminal using Ctrl - Alt - T  and run the below commands to delete the account.

sudo deluser --remove-home accountname

Replace accountname with the account name that you want to delete.


Backup and delete user accounts

If you want to take backup the account before deleting it then you need to create a backup directory to store the user account content and information.

So create a backup directory using below command :

sudo mkdir /accountbackups
sudo chown root /accountbackups
sudo chmod 0700 /accountbackups

Now run the below delete user command with the backup option:

sudo deluser --remove-home --backup-to /accountbackups/ accountname

When you run the above command with backup option, it will take a backup copy of the user’s home folder and delete the user account.


Verify user account

Run the below commands to verify that the user account was deleted or not:

id accountname
grep '^accountname' /etc/passwd

If the above command return no accounts details that means the user accounts were successfully deleted.


The configuration file of deluser command is located at /etc/deluser.conf.

To open configuration file of deluser command, simply run the below command :

cat /etc/deluser.conf

The above command display a output similar like below :

# Remove home directory and mail spool when user is removed
REMOVE_HOME = 0

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

# Backup files before removing them. This options has only an effect if
# REMOVE_HOME or REMOVE_ALL_FILES is set.
BACKUP = 0

# target directory for the backup file
BACKUP_TO = "."

# delete a group even there are still users in this group
ONLY_IF_EMPTY = 0

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

That’s all

If you face any error and issue in above steps , please use comment box below to report.

If our tutorials helped you, please consider buying us a coffee. We appreciate your support!

Thank you for your support.

Leave a Comment

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.

Scroll to Top