Friday, January 1, 2021

Group Administration

 

GROUPS :-

  • Users are assigned to groups with unique group ID numbers (the GID)
  • The group name and GID are stored in /etc/group
  • Each user is given their own private group
  • They can also be added to their groups to gain additional access
  • All users in a group can share files that belong to the group

Note:-

  • A user’s primary group is defined in the /etc/passwd file and Secondary groups are defined in the /etc/group file.
  • The primary group is important because files created by this user will inherit that group affiliation.

Creating a Group with default options :


To create a group the syntax is
  • #groupadd <name for the group>
  • #groupadd tom

Creating a group with user specified group id (GID) :


#groupadd -g 595 ktgroup
 
  Verify it in :
                         #  cat   /etc/group

Modifying the properties of the group :-


To modify the group properties the syntax is :

Changing the GID of the group

                         #groupmod –g 600 javagroup
Verify it in :-    
# cat /etc/group

The options are

  • -g to change the group id
  • -o to override the previous assigned id, if it matches with the new one.
  • -n to change the group name

Changing the name of the group : -

      The syntax for changing the group name is
                        
  •  #groupmod –n <new name > < existing name >
  •  #groupmod –n java   javagroup

Adding and Removing Members to a Group

Adding the members to the group is to add users to the group. To add the members to the .

To add single user to the group

  • #usermod –G <group name > < user name>
  • #usermod –G java  tom

 Adding multiple single or multiple users to the group with various attributes


#gpasswd < option> <arguments> <group name>

Options:
  • -M For Adding Multiple users to a group
  • -A for Adding a group Administrator
  • -a for Adding a single user to a group
  • -d removing a user from a group

syntaxe :

#gpasswd –M <user>,<user>,<user> <group>

#gpasswd –M user1,user2,user3  javagroup

Adding a single user using gpasswd

 #gpasswd –a tom javagroup (verify it in /etc/group)

Making a user as a administrator

 #gpasswd –A  tom javagroup (verify it in /etc/gshadow)

Removing a user from the group
 
#gpasswd –d  tom javagroup

No comments:

Post a Comment