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.
The groupadd command creates or add a group in our system.
Look at the above snapshot, groups php, java, android and spring are created with groupadd command.
The /etc/group file defines the group membership. A user can be a member of more than one group.
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.
The group command tells about the group where current user belongs to.
Look at the above snapshot, user jtp and sssit belongs to the different groups.
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.
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.
With the help of groupmod command you can change the name of an already existing group.
Look at the above snapshot, group spring is changed into sql.
The command groupdel will delete a group permanently from the system.
Look at the above snapshot, group sql is deleted from the system.
Control of group membership can be passed on to another user with gpasswd command.
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.
To remove all the administrators from a group, set an empty administrator list.
Look at the above snapshot, administrator jtp is removed from the group java.