Group identifier

Also known as: GID

On this page 7

A group identifier (GID) is the unsigned integer that the Linux kernel uses to represent a group of users. Group names such as developers exist only for humans; the kernel stores and compares numeric GIDs in file metadata, process credentials and permission checks.

In Linux permissions, the GID is the second half of every file’s ownership, next to the user identifier (UID). Each file carries one owning group, and each process carries a primary GID plus a list of supplementary GIDs. When a process accesses a file, the kernel compares these numbers to decide whether the group permission bits apply.

How the kernel uses group identifiers

Every Linux process holds a set of credentials that include several GIDs. The kernel consults them on each access check, and the distinction between them matters for setgid programs and privilege changes.

CredentialPurposeTypical source
Real GIDIdentifies the group of the user who started the processPrimary group at login
Effective GIDUsed for most permission checksReal GID, or the file group of a setgid binary
Saved set-group-IDAllows a process to switch back to a previous effective GIDCopied from the effective GID at exec
Filesystem GIDUsed for file access checks on LinuxFollows the effective GID by default
Supplementary GIDsAdditional groups that also grant group accessMemberships listed in /etc/group
Group identifiers held by a process

When a process opens a file, the kernel first checks the owner. If the process UID does not match, it checks whether the file GID equals the effective GID or any supplementary GID. If so, the group bits decide access; otherwise the other bits apply. The checks are exclusive, so a matching group with fewer rights does not fall through to more permissive other bits.

Where GIDs are stored and assigned

The mapping between names and numbers lives in /etc/group, while each account’s primary GID is the fourth field of its line in /etc/passwd. Directory services such as LDAP or SSSD can supply the same information through the Name Service Switch, which is why tools call getgrnam() rather than parsing files directly.

A line in /etc/group has four colon-separated fields: name, password placeholder, GID and a comma-separated member list. For example, developers:x:1050:anna,marek defines group 1050 with two supplementary members. Users whose primary group is 1050 do not need to be listed there.

Distributions reserve GID ranges for different purposes. The boundaries are configured in /etc/login.defs and vary slightly between distributions.

RangeUseExamples
0The root grouproot
1 to 99Statically allocated system groupsbin, sys, adm on many systems
100 to 999Dynamically allocated system groupsService accounts created by packages
1000 to 60000Regular user and team groupsGroups created by groupadd or useradd
65534Overflow group for unmapped IDsnogroup or nobody
Typical GID ranges on modern distributions

Modern kernels use 32-bit GIDs, so values up to about 4.29 billion are technically valid. Very high values are common in container user namespaces, where host ranges defined in /etc/subgid are mapped to GIDs inside the container.

The GID works together with several neighboring mechanisms in Linux permissions. Confusing them leads to misconfigured access, so the differences deserve a direct comparison.

ConceptWhat it identifies or controlsRelation to the GID
User identifier (UID)A single accountChecked before the GID
setgid bitEffective GID of a program or group inheritance in a directoryChanges which GID applies
Linux ACLExtra named users and groups per fileAdds groups beyond the single owning GID
chgrpCommand that changes a file’s owning groupWrites a new GID into the inode
umaskDefault permission bits for new filesLimits rights granted to the group
GID and related permission concepts

A setgid directory is especially useful for shared work: new files created inside it inherit the directory’s GID instead of the creator’s primary GID, which keeps team ownership consistent without manual chgrp commands.

Working with GIDs in practice

Administrators inspect and manage GIDs with a small set of standard commands. Most of them accept either names or numbers, but numeric values are authoritative when files move between systems.

  • id prints the UID, primary GID and supplementary groups of the current or a named user.
  • getent group developers resolves a group through all configured name services.
  • groupadd -g 1050 developers creates a group with an explicit GID.
  • usermod -aG developers anna adds a supplementary membership; omitting -a replaces all existing memberships.
  • ls -ln shows numeric owners, which reveals files whose GID no longer has a name.

Supplementary groups are read at login or process start. A user added to a group must start a new session, or use newgrp, before the new GID appears in the process credentials.

Common pitfalls with group identifiers

Because the kernel stores only numbers, problems usually arise when numbers and names drift apart across systems or over time.

ProblemCauseRemedy
Wrong group on NFS filesDifferent GIDs for the same name on client and serverCentral directory service or fixed GID allocation
Orphaned numeric group on filesGroup deleted with groupdel while files remainFind files with find -nogroup and reassign them
New membership has no effectSession started before the changeLog out and in, or start a new shell
Access denied despite group membershipGroup bits more restrictive than intendedReview mode bits, umask and ACL mask
Permission errors in containersGID inside the container maps to another host GIDAlign GIDs or configure user namespace mapping
Typical GID problems and remedies

Reusing a deleted GID for a new group is a quiet security risk: any leftover files with that number immediately become accessible to the new group’s members.

A non-technical view

A group identifier is a number that stands for a team on a Linux computer. People see names like “accounting”. The computer only sees numbers like 1050.

Think of an office where each team has a numbered key card. Every room has a sign that says which team number may enter. If your card carries that number, the door opens. A person can belong to several teams and carry several numbers. The number, not the name, decides access.

A concrete example

A university research lab runs a Linux server where six researchers share experiment data in /srv/lab. The administrator creates a group with groupadd -g 2100 labdata, adds each researcher as a supplementary member, and sets the directory to owner root, group labdata, with mode 2770. The leading 2 is the setgid bit, so every new file inherits GID 2100 automatically.

Later the lab mounts the same storage on a compute cluster over NFS. Files suddenly appear to belong to an unrelated group, because GID 2100 belongs to a different group on the cluster. The administrator moves group definitions to a central LDAP directory with fixed GIDs, after which both systems agree and researchers regain access without changing any file permissions.