How To Remove User From A Group In Linux

4 min read

Group membership is one of the quiet foundations of Linux security. Knowing how to remove a user from a group in Linux is therefore a core administrative skill: it is how you revoke access to shared project folders, take someone off the printer or Docker group, or strip sudo privileges from an account that no longer needs them. Every file you can read, every directory you can enter, and every device you can access is filtered through the groups your account belongs to. This guide walks through every reliable method, explains what happens behind the scenes, and shows how to verify the change actually took effect.

Why Group Membership Matters in Linux

Linux uses a discretionary access control model built on three classes of users: the owner, the group, and everyone else. Each file stores a permission triplet such as rwxr-x---, which means the owner has full control, members of the file's group can read and execute, and other users get nothing And that's really what it comes down to..

There are two distinct kinds of group membership:

  • Primary group — stored in the user account itself (in /etc/passwd, field four). Every new file the user creates automatically belongs to this group. A user has exactly one primary group.
  • Supplementary groups — additional groups listed in /etc/group. These grant access to extra resources without changing file ownership behavior.

When you remove a user from a group, you are removing a supplementary membership. You cannot simply "delete" a primary group from a user, because the account would have no valid group identity — you must reassign it instead. This distinction trips up a lot of beginners, and it is the reason gpasswd -d sometimes appears to do nothing.

Before You Start: Check Current Group Membership

Never remove access blindly. First, confirm exactly what the account currently belongs to.

# All groups for a user (primary + supplementary)
id username

# Just the group names, space separated
groups username

# Primary group only
id -gn username

# Supplementary groups only
id -Gn username

To see the full membership list of one specific group, including its numeric ID:

getent group developers

The output follows the /etc/group format: groupname:x:GID:member1,member2. If the username does not appear after the final colon, that user is not a member — which explains why removal commands may report an error The details matter here..

You will need root privileges for every removal operation, so prefix commands with sudo or switch with sudo -i.

How to Remove a User From a Group in Linux: Step by Step

Method 1: Using gpasswd (Works on All Major Distributions)

gpasswd is part of the shadow-utils package and is the most portable, purpose-built tool for this job.

sudo gpasswd -d alice developers
  • -d (or --delete) removes the user from the group.
  • The group must exist, and the user must actually be a member.

On success you will see something like Removing user alice from group developers. If the user was never a member, the command exits with a non-zero status and the message gpasswd: user 'alice' is not a member of 'developers'.

gpasswd also handles bulk membership management, which is useful when you want to replace a group's member list entirely:

# Set the exact member list (removes everyone not listed)
sudo gpasswd -M bob,carol developers

# Grant or revoke admin rights over the group
sudo gpasswd -A alice developers
sudo gpasswd -A "" developers

Method 2: Using deluser on Debian and Ubuntu

Debian-based systems ship a friendlier Perl wrapper called deluser. It performs consistency checks and is generally considered safer for day-to-day administration.

sudo deluser alice developers

Note the argument order — user first, then group. This is the reverse of gpasswd, and mixing them up is a very common mistake.

deluser is also the tool used to remove accounts entirely, so be careful never to run deluser alice without a group name unless you truly intend to delete the account Took long enough..

Method 3: Using usermod to Replace the Supplementary Group List

usermod modifies account attributes. Its -G flag

...its -G flag. Unlike gpasswd -d, which removes a single user from a specific group, -G replaces the entire supplementary group list for that user.

Out the Door

New Arrivals

These Connect Well

More Good Stuff

Thank you for reading about How To Remove User From A Group In Linux. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home