Lably
Skip to content

Group identifier

Unix/POSIX system account group number; numeric value used to represent a specific group

  • 4 min read
  • 3 chapters

Related on Lably

Through Printer (computing), Peripheral and File system

A group identifier, often abbreviated to GID, is a numeric value used to represent a specific group. The range of values for a GID varies amongst different systems; at the very least, a GID can be between 0 and 32,767, with one restriction: the login group for the superuser must have GID 0. This numeric value is used to refer to groups in the /etc/passwd and /etc/group files or their equivalents. Shadow password files and Network Information Service also refer to numeric GIDs. The group identifier is a necessary component of Unix file systems and processes.

Process attributes

The POSIX standard supports three different GID fields in the process descriptor table, to allow privileged processes to take on different roles dynamically:

Effective group ID

The effective GID (egid) of a process is used for file access checks and may also affect file creation, depending on the semantics of the specific kernel implementation in use and possibly the mount options used. According to BSD Unix semantics, the group ownership given to a newly created file is unconditionally inherited from the group ownership of the directory in which it is created. According to AT&T UNIX System V semantics (also adopted by Linux variants), a newly created file is normally given the group ownership specified by the egid of the process that creates the file. Most filesystems implement a method to select whether BSD or AT&T semantics should be used regarding group ownership of a newly created file; BSD semantics are selected for specific directories when the S_ISGID (s-gid) permission is set.

Real group ID

The real GID (rgid) identify the real group owner of the process.

Saved group ID

The saved group ID is used when a program running with elevated privileges needs to do some unprivileged work temporarily; changing egid from a privileged value (typically 0) to some unprivileged value (anything other than the privileged value) causes the privileged value to be stored in sgid. Later, a program's egid can be set back to the value stored in sgid, so that elevated privileges can be restored; an unprivileged process may set its egid to one of only three values: the value of rgid, the value of sgid, or the value of egid.

Supplementary groups

Every user must be a member of at least one group, the primary group, which is identified by the numeric GID of the user's entry in the passwd database, which can be viewed with the command getent passwd (usually stored in /etc/passwd or LDAP). This group is referred to as the primary group ID. A user may be listed as member of additional groups in the relevant entries in the group database, which can be viewed with getent group (usually stored in /etc/group or LDAP); the IDs of these groups are referred to as supplementary group IDs.

Sign in to keep reading

2 more chapters are free with a Lably account.

More in Computing and communication