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.
| Credential | Purpose | Typical source |
|---|---|---|
| Real GID | Identifies the group of the user who started the process | Primary group at login |
| Effective GID | Used for most permission checks | Real GID, or the file group of a setgid binary |
| Saved set-group-ID | Allows a process to switch back to a previous effective GID | Copied from the effective GID at exec |
| Filesystem GID | Used for file access checks on Linux | Follows the effective GID by default |
| Supplementary GIDs | Additional groups that also grant group access | Memberships listed in /etc/group |
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.
| Range | Use | Examples |
|---|---|---|
| 0 | The root group | root |
| 1 to 99 | Statically allocated system groups | bin, sys, adm on many systems |
| 100 to 999 | Dynamically allocated system groups | Service accounts created by packages |
| 1000 to 60000 | Regular user and team groups | Groups created by groupadd or useradd |
| 65534 | Overflow group for unmapped IDs | nogroup or nobody |
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.
Group identifiers compared with related concepts
The GID works together with several neighboring mechanisms in Linux permissions. Confusing them leads to misconfigured access, so the differences deserve a direct comparison.
| Concept | What it identifies or controls | Relation to the GID |
|---|---|---|
| User identifier (UID) | A single account | Checked before the GID |
| setgid bit | Effective GID of a program or group inheritance in a directory | Changes which GID applies |
| Linux ACL | Extra named users and groups per file | Adds groups beyond the single owning GID |
| chgrp | Command that changes a file’s owning group | Writes a new GID into the inode |
| umask | Default permission bits for new files | Limits rights granted to the group |
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.
idprints the UID, primary GID and supplementary groups of the current or a named user.getent group developersresolves a group through all configured name services.groupadd -g 1050 developerscreates a group with an explicit GID.usermod -aG developers annaadds a supplementary membership; omitting-areplaces all existing memberships.ls -lnshows 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.
| Problem | Cause | Remedy |
|---|---|---|
| Wrong group on NFS files | Different GIDs for the same name on client and server | Central directory service or fixed GID allocation |
| Orphaned numeric group on files | Group deleted with groupdel while files remain | Find files with find -nogroup and reassign them |
| New membership has no effect | Session started before the change | Log out and in, or start a new shell |
| Access denied despite group membership | Group bits more restrictive than intended | Review mode bits, umask and ACL mask |
| Permission errors in containers | GID inside the container maps to another host GID | Align GIDs or configure user namespace mapping |
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.