0% found this document useful (0 votes)
6 views12 pages

Group Administration

The document provides a comprehensive guide on group administration in Linux, detailing commands for creating, modifying, and managing groups using commands like groupadd, groupmod, and gpasswd. It explains the difference between primary and secondary groups, the structure of group entries in system files, and how to manage group passwords and memberships. Additionally, it covers group deletion and the implications of user membership on group deletion.

Uploaded by

Bhupesh Kanire
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views12 pages

Group Administration

The document provides a comprehensive guide on group administration in Linux, detailing commands for creating, modifying, and managing groups using commands like groupadd, groupmod, and gpasswd. It explains the difference between primary and secondary groups, the structure of group entries in system files, and how to manage group passwords and memberships. Additionally, it covers group deletion and the implications of user membership on group deletion.

Uploaded by

Bhupesh Kanire
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Group Administration:

The groupadd command creates a new group account using the values specified on the command
line and the default values from the system. The new group will be entered into the system files as
needed.

There are two types of group:

1. Primary groups: Primary groups are automatically created at the time of user creation. Name of
primary group is same as the user name.

2. Secondary groups : Secondary groups are user define and group id will be unique

it edits on file /etc/group and /etc/gshadow

syntax:

# groupadd <groupname>

eg:

[root@localhost ~]# groupadd redhat

[root@localhost ~]# tail -1 /etc/group

redhat:x:1001:

redhat :x : 1001:
1 2 3 4

➢ field 1: Group name.

➢ field 2: Redirected Password. (link of the /etc/gshadow file)

➢ field 3: Group ID

➢ field 4: User list (group members


[root@localhost ~]# tail -1 /etc/gshadow

redhat:!::

# group customize
# syntax:

#groupadd <option> <argument> <groupname>

eg:

[root@localhost ~]# groupadd -g 5050 admin

[root@localhost ~]# tail -1 /etc/group

admin:x:5050:

GROUP MODIFICATION

cmd: groupmod

this command is use to modify the attributes of group

synatx:

# groupmod <option> <argument> <existing groupname>

options:

-g  groupid

-n  group name

-o  non-unique

eg:

[root@localhost ~]# groupadd testing


[root@localhost ~]# tail -1 /etc/group

testing:x:5051:

[root@localhost ~]# groupmod -g 3030 testing

[root@localhost ~]# tail -1 /etc/group

testing:x:3030:

[root@localhost ~]# groupmod -n sales testing

[root@localhost ~]# tail -1 /etc/group

sales:x:3030:

[root@localhost ~]# tail -2 /etc/group

admin:x:5050:

sales:x:3030:

[root@localhost ~]# groupmod -o -g 5050 sales

[root@localhost ~]# tail -2 /etc/group

admin:x:5050:

sales:x:5050:

GROUP PASSWORD MANAGEMENT

cmd: gpasswd

/etc/group, /etc/gshadow

syntax:

#gpasswd <groupname>  use to set group password


#gpasswd <option> <argument> <group>

# options:

-a --> add members in group

-A --> create group administration

-M --> add multiple users in group

-r --> remove group password

-d -> delete user from group

eg:

[root@localhost ~]# groupadd rhcsagroup

[root@localhost ~]# tail -1 /etc/group

rhcsagroup:x:5051:

[root@localhost ~]# tail -1 /etc/gshadow

rhcsagroup:!::

[root@localhost ~]# gpasswd rhcsagroup

Changing the password for group rhcsagroup

New Password: redhat

Re-enter new password: redhat

[root@localhost ~]# tail -1 /etc/gshadow

rhcsagroup:$6$4rt7XFvfh4Z$jLwzAMiXsWqoHXHgz1ayuU7OBA2enOTY9oSDMaVmSkeBmLuKCjVcUf
mwhN5LJsfQss.tutHqlonFz/0pvAUOg1::
rhcsagroup :$qlonFz/0pvAUOg1 : :
1 2 3 4

field1: groupname

field2: encrypted password

field3: group admin

field4: grouo members list

[root@localhost ~]# useradd jack; useradd jerry; useradd john

[root@localhost ~]# tail -3 /etc/group

jack:x:5052:

jerry:x:1002:

john:x:1003:

[root@localhost ~]# groupadd rhce

[root@localhost ~]# tail -1 /etc/group

rhce:x:5053:

[root@localhost ~]# gpasswd rhce

Changing the password for group rhce

New Password:

Re-enter new password:

[root@localhost ~]# tail -1 /etc/gshadow

rhce:$6$0ta9X6kMQR/q$HiliFlUFwwwXPtCRzyuhhVu6XxUtcvoPjFb2lBsOIQiINv4VjB/qg9VcN7Kwy4Q
nla3UguPnhpgB12c2ffi6b1::

[root@localhost ~]#
[root@localhost ~]# # -r --> remove group password

[root@localhost ~]# gpasswd -r rhce

[root@localhost ~]# tail -1 /etc/gshadow

rhce:::

[root@localhost ~]# # -a --> add user in group

[root@localhost ~]#

[root@localhost ~]# gpasswd -a jack rhce

Adding user jack to group rhce

[root@localhost ~]# tail -1 /etc/group

rhce:x:5053:jack

[root@localhost ~]# tail -1 /etc/gshadow

rhce:::jack

[root@localhost ~]# gpasswd -a jerry rhce

Adding user jerry to group rhce

[root@localhost ~]# tail -1 /etc/group

rhce:x:5053:jack,jerry

[root@localhost ~]# useradd harry

[root@localhost ~]# gpasswd -M john,harry rhce

[root@localhost ~]# tail -2 /etc/group

rhce:x:5053:john,harry

harry:x:1004:

[root@localhost ~]# gpasswd -M john,harry,jerry,jack rhce


[root@localhost ~]# tail -2 /etc/group

rhce:x:5053:john,harry,jerry,jack

harry:x:1004:

[root@localhost ~]# tail -2 /etc/group

rhce:x:5053:john,harry,jerry,jack

harry:x:1004:

-A --> group admin

[root@localhost ~]# gpasswd -A john rhce

[root@localhost ~]# tail -2 /etc/gshadow

rhce::john:john,harry,jerry,jack

harry:!::

[root@localhost ~]# gpasswd -A jerry rhce

[root@localhost ~]# tail -2 /etc/gshadow

rhce::jerry:john,harry,jerry,jack

harry:!::

[root@localhost ~]# gpasswd -A jerry,john rhce

[root@localhost ~]# tail -2 /etc/gshadow

rhce::jerry,john:john,harry,jerry,jack

harry:!::

# -d --> delete user from group

[root@localhost ~]# gpasswd -d jack rhce


Removing user jack from group rhce

[root@localhost ~]# tail -2 /etc/gshadow

rhce::jerry,john:john,harry,jerry

harry:!::

[root@localhost ~]# gpasswd -d harry,jerry rhce

Removing user harry,jerry from group rhce

gpasswd: user 'harry,jerry' is not a member of 'rhce'

to check users in group

cmd:groups

[root@localhost ~]# tail /etc/group

student:x:1000:

redhat:x:1001:

admin:x:5050:

sales:x:5050:

rhcsagroup:x:5051:

jack:x:5052:

jerry:x:1002:

john:x:1003:

rhce:x:5053:john,harry,jerry

harry:x:1004:

[root@localhost ~]# gpasswd -a john rhcsagroup

Adding user john to group rhcsagroup

[root@localhost ~]# gpasswd -a john admin


Adding user john to group admin

[root@localhost ~]# gpasswd -a john sales

Adding user john to group sales

[root@localhost ~]# groups john

john : john sales rhcsagroup rhce

[root@localhost ~]# tail /etc/group

student:x:1000:

redhat:x:1001:

admin:x:5050:john

sales:x:5050:john

rhcsagroup:x:5051:john

jack:x:5052:

jerry:x:1002:

john:x:1003:

rhce:x:5053:john,harry,jerry

harry:x:1004:

[root@localhost ~]# id john

uid=1003(john) gid=1003(john) groups=1003(john),5050(sales),5051(rhcsagroup),5053(rhce)

#group deletion
#cmd: groupdel

#syntax:

#groupdel <groupname>

#eg:
[root@localhost ~]# groupadd linux

[root@localhost ~]# gpasswd linux

Changing the password for group linux

New Password: redhat

Re-enter new password: redhat

[root@localhost ~]# tail -1 /etc/group

linux:x:5054:

[root@localhost ~]# tail -1 /etc/gshadow

linux:$6$zFPDwevpHA/VLd$PoCWtvQ7JcRGfLaqRaCc3AgSkGuSH7A89R3VBcUmP6oxAorr/c9SmwRo
mVnJYZODccTUSJXy4fYjll12Km4WA/::

[root@localhost ~]# gpasswd -a jack linux

Adding user jack to group linux

[root@localhost ~]# tail -1 /etc/group

linux:x:5054:jack

[root@localhost ~]# groupdel linux

[root@localhost ~]# tail /etc/group

student:x:1000:

redhat:x:1001:

admin:x:5050:john

sales:x:5050:john

rhcsagroup:x:5051:john

jack:x:5052:

jerry:x:1002:

john:x:1003:
rhce:x:5053:john,harry,jerry

harry:x:1004:

# -f --> delete group forcefully

[root@localhost ~]# #groupdel -f <group name>

[root@localhost ~]# groupdel admin

[root@localhost ~]# tail /etc/group

tcpdump:x:72:

student:x:1000:

redhat:x:1001:

sales:x:5050:john

rhcsagroup:x:5051:john

jack:x:5052:

jerry:x:1002:

john:x:1003:

rhce:x:5053:john,harry,jerry

harry:x:1004:

[root@localhost ~]# useradd sam

[root@localhost ~]# tail -1 /etc/passwd

sam:x:1005:1005::/home/sam:/bin/bash

[root@localhost ~]# tail -1 /etc/group

sam:x:1005:

[root@localhost ~]#
[root@localhost ~]# gpasswd -a john sam

Adding user john to group sam

[root@localhost ~]# tail -1 /etc/group

sam:x:1005:john

[root@localhost ~]# userdel sam

userdel: group sam not removed because it has other members.

[root@localhost ~]#

[root@localhost ~]# tail -1 /etc/passwd

harry:x:1004:1004::/home/harry:/bin/bash

[root@localhost ~]#

[root@localhost ~]# tail -1 /etc/shadow

harry:!!:19032:0:99999:7:::

[root@localhost ~]#

[root@localhost ~]# tail -1 /etc/group

sam:x:1005:john

[root@localhost ~]# tail -1 /etc/gshadow

sam:!::john

[root@localhost ~]# groupdel sam

[root@localhost ~]# tail -1 /etc/group

harry:x:1004:

[root@localhost ~]# tail -1 /etc/gshadow

harry:!::

[root@localhost ~]#

[root@localhost ~]#

You might also like