Javatpoint Logo
Javatpoint Logo

Linux Groups

Users can be listed in different groups. Group allow us to set permission on the group level instead of setting the permission on individual level.

Every Linux distribution have a graphical tool to manage groups. Groups can be managed by graphical tools, command line tools and by vi or vigr depending upon the user's experience. Only experienced users should use vi or vigr to manage groups, since it will do proper locking or changes in the file.

groupadd

The groupadd command creates or add a group in our system.

Syntax:

Example:

Linux Local Group1

Look at the above snapshot, groups php, java, android and spring are created with groupadd command.


Group File

The /etc/group file defines the group membership. A user can be a member of more than one group.

Syntax:

Linux Local Group2

Look at the above snapshot, first column indicates group name, second is the group's encrypted password which may remain empty also, third is group identification (GID) and fourth is the list of members. Fourth list is empty as these groups do not have members.

Groups

The group command tells about the group where current user belongs to.

Syntax:

Linux Local Group3

Look at the above snapshot, user jtp and sssit belongs to the different groups.


usermod

The group members can be edited with usermod or useradd command. If a group is not listed then by default, usermod command will remove the user from every group of which he is a member. Here, -a (append) option is used to prevent this from happening.

Syntax:

Example:

Linux Local Group4

Look at the above snapshot, we have displayed the list of /etc/group. User akki and abc are added into the group php, user jtp is added into java.


groupmod

With the help of groupmod command you can change the name of an already existing group.

Syntax:

Example:

Linux Local Group5

Look at the above snapshot, group spring is changed into sql.


gruopdel

The command groupdel will delete a group permanently from the system.

Syntax:

Example:

Linux Local Group6

Look at the above snapshot, group sql is deleted from the system.


gpasswd

Control of group membership can be passed on to another user with gpasswd command.

Syntax:

Example:

Linux Local Group7

Look at the above snapshot, we have passed the membership of java to the user with command "gpasswd -A jtp java". Then we su to jtp and add aaa to java.

Group administrators need not to be a member of the group. They can add or remove a member without being a member of that group.

File /etc/gshadow keeps the information about the group administrators as shown in below snapshot.

Linux Local Group8

To remove all the administrators from a group, set an empty administrator list.

Syntax:

Example:

Linux Local Group9

Look at the above snapshot, administrator jtp is removed from the group java.





Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA