GROUP ADMINISTRATION IN LINUX

Different kinds of users in Linux

There are two main type of groups in Linux OS. Primary group and Secondary group or Supplementary group.

Primary group is auto generated when we add users in Linux. When user creates files or directories these files will receives owner and group owner settings as the creator user.
Secondary groups we are going to create in Linux for user administration and permission management. We can add users as required to assign permissions in the filesystem. Secondary group also often called as Supplementary groups.


Add new group to Linux


#groupadd group_name
#groupadd cisco
#groupadd HR
#groupadd Purchase
#groupadd test_group
      

Change name of existing group


#groupmod -n Project test_group


Add single user in secondary group


#usermod -G cisco user1

Add multiple users in a group


                                    
#gpasswd –M user100,user101 demogroup
      

Add multiple users in groups


#gpasswd -M user1,user2 cisco
      

Change users Primary group to HR


#usermod -g HR user2
      

Remove user from group


#gpasswd -d user2 cisco
      

Add existing user to different groups

We are going to use user2 for this lab
Groups: ccna, ccnp , ccie

#groupadd ccna
#groupadd ccnp
#groupadd ccie
#usermod -aG ccna user2
#usermod -aG ccnp user2
#usermod -aG ccie user2
#cat /etc/group          Verify the result      

Delete a group from Linux


#groupdel Purchase
#groupdel demogroup