Delete a user account in Ubuntu with the deluser command

The deluser command is used to delete user account in Ubuntu. The command usually run with the --remove-home option, which removes the user and the user's home directory, along with the user's mailbox (mail spool).

deluser --remove-home user_name

For example, to delete a user called sysadmin from your Ubuntu server, you will run:

deluser --remove-home sysadmin
Delete a user account in Ubuntu with the deluser command

Without the --remove-home flag, deluser command removes the user entry from the /etc/passwd file, but leaves the user's home directory and mailbox.

Note that deluser command need superuser (sudo) or root privileges to delete a user from the Ubuntu server.

It is also a good idea to backup user's files before deleting the home directory. This can be done with --backup option.

deluser --remove-home --backup sysadmin

This will create a backup file called sysadmin.tar.bz2 (named After the user) in the current working directory.

ubuntu delete user


If you use --remove-all-files option the command will remove all files on the Ubuntu server/desktop owned by the user along with the user's home directory.

deluser --remove-all-files sysadmin

An important thing to keep in mind is that, the deluser command also removes the user's supplementary group (Primary group) if it has no other members.