Linux uses groups to organize users in the system. Groups are collections of accounts with certain shared features and access controls. Like users, a group also have a name, which is associated to a number known as the Group ID (GID), and is generally the same as the UID. Local group information is stored in the /etc/group file. There are two types of group associated with user accounts:
- Primary groups:
- Every user has only one primary group.
- It is the default group of a user to which he belongs.
- Each local user's primary group is defined by the GID number of the group listed in the third field of the /etc/passwd file.
- By default, the primary group owns the new files created by the user.
- Generally, the primary group of a newly created user will have the same name as the user. Each user is the only member of this private primary group of the user.
- Supplementary groups:
- Each can be associated with 0 or more supplementary groups.
- Each local user's secondary group entry is defined in the last field of the /etc/group file. This file contains a comma-separated list of users in the last field, which determines the group membership of users for a group.
- Supplementary group membership helps in implementing access rights, privileges, and security considerations to files and other resources in the system. The various fields of the /etc/group file are as follows:
groupname : password : GID : <comma separated list of users who belong to this group>
The following screenshot displays the contents of the last two line of the /etc/group file: