This article describes the steps to remove users from groups in Ubuntu Linux.
Our previous post showed you how to add users to groups in Ubuntu Linux. This post shows you the other way around – removing users from groups in Ubuntu Linux.
A group is a container that can organize or administer user accounts. Accounts in the same group will access and manage resources belonging to that group.
Every account on a Ubuntu Linux system belongs to one or more groups. There are two types of groups: Primary and secondary groups.
Below is a post on how to add users to groups in Ubuntu Linux.
How to add a user to a group in Ubuntu Linux
Removing users from a group in Ubuntu Linux
As stated above, groups help administrators efficiently organize or administer user accounts’ access to resources. With grouping, you can provide access to a resource, and all group members will access it.
You can use the steps below to remove the account if a user is no longer needed in a group.
The format to remove a user from a group is as follows:
sudo deluser username groupname
The deluser command is a script that uses the usermod command to add or remove users from groups.
For example, you remove the user named geekrewind from the developers‘ group; you run the commands below.
sudo deluser geekrewind developers
A user account must be a member of one primary group – typically a group with a similar name to the user. You can change the primary group of a user account.
For example, you use the commands below to change the primary group of the user geekrewind to developers.
sudo usermod -g developers geekrewind
Doing that will remove the geekrewind user from its primary group to a new developers group as its primary group.
You can then remove the account from its previous primary group.
To verify a user group, run the command format below.
groups username
That should do it!
Conclusion:
- Groups in Ubuntu Linux help administrators efficiently organize or administer user accounts’ access to resources
- The format to remove a user from a group is “sudo deluser username groupname”
- The deluser command uses the usermod command to add or remove users from groups
- It’s important to note that a user account must be a member of one primary group
- You can change the primary group of a user account using the usermod command
- Verifying a user group can be done by running the “groups username” command
Leave a Reply Cancel reply