+4 votes
39 views
Add or remove User Group Linux

in Linux/Unix by (551k points)
reopened | 39 views

1 Answer

+5 votes
Best answer

How to add or remove a user from a group in Linux

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) 
image

 

Step 2

We list the groups of the user who has logged in:
 groups 
image

 

Step 3

To add a user to a new group we execute the following:
 sudo usermod -aG (group) (user) 
image

 

Step 4

Check the change:
 groups (user) 
image

 

step 5

To remove a user from a group we execute:
 sudo gpasswd -d (user) (group) 
image

 

step 6

Check the change:
 groups (user) 
image

 

That's how simple and functional it is to add or remove a user from a group in Linux.

 


by (3.5m points)
edited

Related questions

+3 votes
1 answer
asked Nov 4, 2019 in Linux / Unix by backtothefuture (551k points) | 254 views
+3 votes
1 answer
asked Apr 17, 2023 in Linux/Unix by backtothefuture (551k points) | 38 views
+4 votes
1 answer
asked Nov 11, 2022 in Linux/Unix by backtothefuture (551k points) | 37 views
+5 votes
1 answer
asked May 5, 2023 in Linux/Unix by backtothefuture (551k points) | 49 views
+5 votes
1 answer
Sponsored articles cost $40 per post. You can contact us via Feedback
10,634 questions
10,766 answers
510 comments
3 users