Step-by-Step Guide to Group Management in Linux for appending the user's..

Step-by-Step Guide to Group Management in Linux for appending the user's..

Last Blog Review -

In the last blog we learnt, how to manage the user’s in the Linux. But if we have group of user’s working in same department and want to manage same permissions for all them at once, then we create a user-group in Linux….

User-Group Management one-by-one -

All the groups which are created are stored in directory /etc/group directory. So, we create a group first and then add the user's in it one-by-one.

A) Group using append argument -a = To add/append the user one by one to the group with existing user's in the group.

  • Lets create a group named appgr first using command "sudo groupadd appgr". Once you create the group you can check by going inside the directory /etc/group.

    So, as you see here the group "appgr" is created. Also, we can see the user "ubuntu" is present in this directory because the user is also considered an individual group. Now as you see "appgr:x:1001:" doesn't have any user named ahead of it. Once we append user one by one they will be added in the group and we can check that.

i-XXXXXXXXXXXXXXXXX (EC2)
--------------------------
ubuntu@ip--------:~$ sudo groupadd appgr
ubuntu@ip--------:~$ sudo cat /etc/group
.
.
ubuntu:x:1000:
appgr:x:1001:
  • Let’s create user's for adding them in appgr group. Lets say the user's are appus1, appus2, appus3. Now we will add only appus1 in the appgr group then using "-a" command i.e. append we will append the new users with the old users in the group. So, in this way we can add new users to group without disturbing the existing user's.
iXXXXXXXXXXXXXXXXX- (EC2)
--------------------------
ubuntu@ip--------:~$ sudo useradd appus1 -m
ubuntu@ip--------:~$ sudo passwd appus1
New password: 
Retype new password: 
passwd: password updated successfully
ubuntu@ip--------:~$ sudo useradd appus2 -m
ubuntu@ip--------:~$ sudo passwd appus2
New password: 
Retype new password: 
passwd: password updated successfully
ubuntu@ip--------:~$ sudo useradd appus3 -m
ubuntu@ip--------:~$ sudo passwd appus3
New password: 
Retype new password: 
passwd: password updated successfully
  • Now we have created 3 user's. Next we will add/append the user's one by one in the group using command "gpasswd -a username's group-name".
i-XXXXXXXXXXXXXXXXXX(EC2)
--------------------------
ubuntu@ip--------:~$ sudo gpasswd -a appus1 appgr
Adding user appus1 to group appgr
ubuntu@ip--------:~$ sudo cat /etc/group  
.
.
ubuntu:x:1000:
appgr:x:1001:appus1
appus1:x:1002:
appus2:x:1003:
appus3:x:1004:
ubuntu@ip--------:~$
  • So, see here you have added only "appus1" user in the "appgr" group that's why it is showing only one user in front of the group "appgr:x:1001:appus1". Next I want to add "appus2" in the group as well. So, I will append that user in the group as well.
i-XXXXXXXXXXXXXXXXXX (EC2)
--------------------------
ubuntu@ip--------:~$ sudo gpasswd -a appus2 appgr
Adding user appus2 to group appgr
ubuntu@ip--------:~$ sudo cat /etc/group
.

ubuntu:x:1000:
appgr:x:1001:appus1,appus2
appus1:x:1002:
appus2:x:1003:
appus3:x:1004:
ubuntu@ip--------:~$
  • Now I will add appus3 in the appgr as well.
i-XXXXXXXXXXXXXXXXXX (EC2)
--------------------------
ubuntu@ip--------:~$ sudo gpasswd -a appus3 appgr 
Adding user appus3 to group appgr
ubuntu@ip--------:~$ sudo cat /etc/group      
ubuntu:x:1000:
appgr:x:1001:appus1,appus2,appus3
appus1:x:1002:
appus2:x:1003:
appus3:x:1004:
ubuntu@ip--------:~$

Conclusion -

In this way we can create group and add the user’s to the group one by one, which is important for providing same set of permissions to the people belonging to same department having same set of actions to perform on a assignment. And adding them one by one will help to add new user’s getting adding to the project later on, without over-riding the permissions of existing user.

💡
Thanks for reading! I’d love to hear your thoughts—what resonated with you the most? Share your insights in the comments below! If you found this post helpful, don’t forget to share, like and subscribe for more content like this. Let’s keep the conversation going!