Linux GroupsUsers 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: Look at the above snapshot, groups php, java, android and spring are created with groupadd command. Group FileThe /etc/group file defines the group membership. A user can be a member of more than one group. Syntax: 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. GroupsThe group command tells about the group where current user belongs to. Syntax: Look at the above snapshot, user jtp and sssit belongs to the different groups. usermodThe 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: 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. groupmodWith the help of groupmod command you can change the name of an already existing group. Syntax: Example: Look at the above snapshot, group spring is changed into sql. gruopdelThe command groupdel will delete a group permanently from the system. Syntax: Example: Look at the above snapshot, group sql is deleted from the system. gpasswdControl of group membership can be passed on to another user with gpasswd command. Syntax: Example: 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. Syntax: Example: Look at the above snapshot, administrator jtp is removed from the group java. Next TopicAdd User to Group |