Sidhak Verma
Myself Sidhak I am a student and a content writer. I share my ideas on social media and finding ways of earning money online on the internet.
Linux includes a highly adaptable user and group administration system that enables administrators to manage access permissions. In Linux, groups are collections...
Image Credits: canva
Linux includes a highly adaptable user and group administration system that enables administrators to manage access permissions. In Linux, groups are collections of users with similar access rights, which makes managing multiple users easier.
Sometimes, a user needs to be removed from a group. This can happen if a department changes, if there are security issues, or if a project is finished. Removing a user from a group in Linux is a simple task, but there are several ways to do so, each with its own use case.
This article will show you how to remove a user from a Linux group. It will also cover troubleshooting steps and best practices for managing user access effectively.
In Linux, user groups are collections of user accounts with the same access permissions. System administrators assign permissions to groups rather than individual users, and all members inherit those privileges.
Linux typically utilises two types of groups:
Effective user group management is critical for:
Before removing a user from a group, you need to determine which groups they belong to.
The simplest way to view a user’s group memberships is:
groups username
Example:
groups alice
Output:
alice: alice sudo docker developers
This means Alice is a member of the sudo, docker, and developer groups.
To obtain a more detailed result, use:
id username
Example:
uid=1002(alice) gid=1002(alice) groups=1002(alice),27(sudo),999(docker),1003(developers)
You can manually inspect group memberships by checking the /etc/group file:
cat /etc/group | grep username
The gpasswd command allows you to manage group memberships.
sudo gpasswd -d username groupname
To remove Alice from the Docker group:
sudo gpasswd -d alice docker
Output:
Removing user alice from group docker
The deluser command is another useful tool for removing a user from a group.
sudo deluser username groupname
sudo deluser alice docker
The usermod command changes user properties, including group membership.
sudo usermod -G group1,group2 username
sudo usermod -G sudo alice
To verify:
groups alice
If the Docker is missing, it means the removal was successful.
Removing a user from a group in Linux is an important activity for system administrators. To keep security and organisation, you must verify changes when using gpasswd, deluser, or usermod. Always follow best practices.