ubuntu remove user

If you’re getting started with Ubuntu, it’s important to learn how to manage users, groups, and permissions. The deluser and userdel commands are typically used to delete users. 

If you only want to remove users from certain groups rather than deleting them entirely, the usermod command will also work. Or, you can even ditch the command line entirely and remove users from the GUI.

Remove User from Control Center

The user settings applet is limited in that you can’t properly manage groups with it. But for simply removing users, it’s one of the most convenient options.

  1. Search and open ‘Users’ from the Activities overview.
    user settings ubuntu
  2. Click on the Unlock button and enter your password for authentication.
    unlock user settings ubuntu
  3. Click on Remove User from the bottom and select whether you want to keep or delete the user’s files.
    remove user ubuntu settings

Remove User from Command Line

The /etc/passwd file keeps track of accounts on the system. You can first check the list of accounts with

cat /etc/passwd

Then, you can specify the user account to delete. We’ll remove a user named anup.

sudo deluser anup
sudo userdel anup

You can use id anup or check the passwd file again to verify the change.

Remove Home Directory

If you want to completely remove a user from the system, you should use the --remove option to remove the user’s home directory and all files within.

sudo userdel -r anup

You can also use deluser with the --remove-all-files flag to delete all files owned by the user.

sudo deluser --remove-all-files anup

If encounter errors and are unable to delete the home directory like this, you can manually delete it like so

sudo rm -rf /home/anup

Remove User from Group

If you’re managing permissions, you may want to remove a user from certain groups rather than delete them entirely. For instance, it’s common to add and remove users from the sudo group.

You can use deluser and specify the group to remove the user from, like so

sudo deluser anup sudo

Or, you can use usermod and specify the groups you want the user to be a part of. As sudo isn’t included in the following example, the user anup will no longer be a member of sudo.

sudo usermod -G anup,users anup

In either case, you can verify the change like so

anup groups
Anup Thapa

Senior Writer

Anup Thapa is a Linux enthusiast with an extensive background in computer hardware and networking. His goal is to effectively communicate technical concepts in a simplified form understandable by new Linux users. To this end, he mainly writes beginner-friendly tutorials and troubleshooting guides. Outside of work, he enjoys reading up on a range of topics, traveling, working out, and MOBAs.