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.

Each user is a member of at least one group, called a primary group. In addition, a user can be a member of an unlimited number of secondary groups. Group membership can be used to control the files that a user can read and edit. For example, if two users are working on the same project you might put them in the same group so they can edit a particular file that other users cannot access.

  • 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 lbgroup
[root@localhost ~]# groupadd lbgroup
[root@localhost ~]# tail /etc/group
postgres:x:26:
postdrop:x:90:
postfix:x:89:
dovecot:x:97:
dovenull:x:383:
oprofile:x:16:
tcpdump:x:72:
lb:x:1000:lb
lbuser:x:1001:
lbgroup:x:1002:
[root@localhost ~]#

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

  • #groupadd <option> <name for the group>
  • #groupadd -g 595 lbgroup
  • Verify it in /etc/group
[root@localhost ~]# groupadd -g 595 lbgroup
[root@localhost ~]# tail /etc/group
postgres:x:26:
postdrop:x:90:
postfix:x:89:
dovecot:x:97:
dovenull:x:383:
oprofile:x:16:
tcpdump:x:72:
lb:x:1000:lb
lbuser:x:1001:
lbgroup:x:595:
[root@localhost ~]#

Modifying the properties of the group:

  • To modify the group properties the syntax is
  • #groupmod <option> <arguments><group name>
  • The options are
  •    -g    to change the group id
  •    -o    to override the previously assigned id, if it matches with the new one.
  •    -n    to change the group name.

Changing the GID of the group

  •  #groupmod –g 600 lbgroup
  • Verify it in /etc/group
[root@localhost ~]# groupmod -g 600 lbgroup 
[root@localhost ~]# tail /etc/group
postgres:x:26:
postdrop:x:90:
postfix:x:89:
dovecot:x:97:
dovenull:x:383:
oprofile:x:16:
tcpdump:x:72:
lb:x:1000:lb
lbuser:x:1001:
lbgroup:x:600:
[root@localhost ~]# 

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 group the syntaxes are
  • To add single user to the group
  • #usermod –G < group name>< user name>
  • #usermod –G lbgroup lbuser
[root@localhost ~]# usermod –G lbgroup lbuser
[root@localhost ~]# grep lbgroup /etc/group
lbgroup:x:600:lbuser
[root@localhost ~]#

Leave a Reply

Your email address will not be published. Required fields are marked *