Linux /etc/group file

In Linux, each user is assigned at least one group. All the information related to groups such as group name, group members, and group ID are stored in /etc/group file. By default, when a new user is created, a group with the same name as that of username is also created at the same time and the newly created user become a member of that group. You can modify this behavior as well.

There are four fields per line entry and are separated by a colon(:). Each row in this file represents entry of one group. Below image is a sample entry from group file-

Linux group file
  1. Group Name- This field stores a name of the group.
  2. Group Password- This field specifies a password of the group and is generally left blank. A value of x means password is stored in gshadow file for security reason. A blank value means no password is assigned to this group.
  3. Group ID(GID)- Every group is assigned a GID and this field is the place where GID is stored. Group ID is also placed in GID field(fourth field) of /etc/passwd file
  4. Group Members- This field stores the usernames that belong to the group.

Note: More than one user can become members of a single group. A user can be a member of several groups.

Example entry of Linux /etc/group file

sysadmin:x:502:madhav,surbhi,vrinda,raghav,root

The above line shows group information for group sysadmin and below it is explained in detail-

  1. The group name is sysadmin
  2. This group is assigned a password that is stored in gshadow file.
  3. 502 is the Group ID of sysadmin group.
  4. madhav, surbhi, vrinda, raghav, and root are members of this group.