In Linux, groups are an essential part of the system structure since they are designed to grant permissions that allow a user to modify files or directories, in Linux there are primary groups and secondary groups, to understand this the main group a little A user's name refers to the default group associated with the account, directories and files created by the user will use that group ID, and child groups are groups in which the user is a member but not their parent group. Using users in groups in Linux is a powerful tool that will allow us to do full security and accessibility management in our system when there are multiple users..
Within Linux, users are represented by a series of accounts that we create to identify people or processes that have access to our system. We can create groups as a set of users that are going to share a series of permissions and privileges and that can be used to manage a series of permissions on files and directories in a concrete way. In addition, a user can be a member of one or several groups, thus being able to access files and directories, being able to modify them in different groups. An organization of the system in groups allows a specific distribution of those permissions and making the structure of our system much simpler since the permissions of a group are going to be applied automatically to all the users that make up said group.
In this tutorial we will teach you how to add or remove a user from a group in Linux..
To stay up to date, remember to subscribe to our YouTube channel!
SUBSCRIBE ON YOUTUBE
How to add or remove a user from a group in Linux
Step 1
We open the terminal and list the groups of a specific user by executing:
groups (user)
Step 2
We list the groups of the user who has logged in:
groups
Step 3
To add a user to a new group we execute the following:
sudo usermod -aG (group) (user)
Step 4
Check the change:
groups (user)
step 5
To remove a user from a group we execute:
sudo gpasswd -d (user) (group)
step 6
Check the change:
groups (user)
That's how simple and functional it is to add or remove a user from a group in Linux.