• Start Here
    • How to Install Linux
    • Which Distro To Choose
    • 10 Best Linux Distributions of 2023
  • Distros
    • Ubuntu
  • Linux Commands
  • Virtualization
  • Open Source
Linux Start
  • Start Here
    • How to Install Linux
    • Which Distro To Choose
    • 10 Best Linux Distributions of 2023
  • Distros
    • Ubuntu
  • Linux Commands
  • Virtualization
  • Open Source
Linux Start
Home»Distros»Ubuntu»How To Remove Users On Ubuntu

How To Remove Users On Ubuntu

Anup ThapaBy Anup ThapaMarch 22, 2023 Ubuntu 2 Mins Read

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
  • LinkedIn

Anup Thapa is a Linux enthusiast with an extensive background in computer hardware and networking. At LinuxStart, Anup is an integral part of our editorial team. 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 experimenting with different Linux distros and reading up on things like networking and virtualization.

Leave A Reply Cancel Reply

Table of Contents
  • Remove User from Control Center
  • Remove User from Command Line
    • Remove Home Directory
    • Remove User from Group
Linux Start
Guides

What is the Linux Kernel?

The Linux Kernel is the core of the Linux operating system and is central to…

How To Install Linux Mint

How To Install Linux on VirtualBox

Getting Started with Linux

How to Install Linux

10 Best Linux Distros of 2023

Which Linux Distro Should You Choose? A Complete Guide to Help You Decide

© 2023 LinuxStart.com

Type above and press Enter to search. Press Esc to cancel.