How to Remove Users from Groups in Ubuntu
Removing users from groups in Ubuntu lets you take away their special permissions. A group in Ubuntu acts like a shared permission club for user accounts, deciding who can access certain files or features.
You can easily manage these permissions using commands in the Ubuntu terminal, the text-based window where you type instructions. For example, Ubuntu 22.04 LTS uses this system to control access.
Taking a user out of a group removes their access to things that group controlled. This is important for keeping your system secure and organized, especially when a user no longer needs certain privileges.
You remove users from groups in Ubuntu using the command line. Type `sudo deluser username groupname` to remove a specific user from a group. You can verify group membership by running `groups username`.
Removing users from a group in Ubuntu Linux
Removing users from groups in Ubuntu Linux is quite straightforward with a single command.
A user can be removed from an Ubuntu group when they no longer require access to shared files or permissions. Removing a user from the ‘sudo’ group, for instance, revokes their administrator privileges.
The command format to remove a user from a group looks like this:
sudo deluser username groupname
The deluser command itself is a script that leverages the usermod command to manage user group memberships.
To remove a user from a group in Ubuntu, you execute a specific command in the terminal. For example, to remove the user named `geekrewind` from the `developers` group, you would run the command `sudo gpasswd -d geekrewind developers`. This command targets the specific user and group, ensuring accurate removal without requiring deep knowledge of other system settings.
sudo deluser geekrewind developers
A user account must always belong to at least one primary group. This is typically a group named after the user. You can change a user’s primary group if needed.
For example, use the commands below to change the primary group for the user geekrewind to developers.
sudo usermod -g developers geekrewind
This action moves the geekrewind user from its current primary group to the developers group.
You can then remove the account from its previous primary group.
groups username
This process is complete.
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
How do I remove a user from the group?
Once you’ve identified the user to remove from the group, click on their entry. Then, select ‘Remove from group’ to confirm.
How to remove multiple users together from a group in Linux?
Removing multiple users from a group in Linux can be done efficiently, even though some commands only allow you to remove one user at a time.
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
No comments yet — be the first to share your thoughts!