In Linux, GID stands for Group Identifier or Group ID. It is a unique numerical identifier assigned to each group in the system, which is a fundamental part of Linux's user and permission management system.
The GID plays a crucial role in controlling access to files and directories. When a user creates a file, the file's group ownership is initially inherited from the user's primary group. The system then uses the file's permissions---set for the owner, the group, and others---to determine what actions a user can perform on that file.
If a user is a member of the group that owns a file (i.e., their GID or supplementary GIDs match the file's group GID), they are granted the access permissions defined for the group.
GID Range Group Type Typical Use
0 - 99 Reserved for kernel System-level processes
100 - 999 System groups Groups for system services/admin
A particularly important GID is 0, which is assigned to the root group. Belonging to this group grants extensive system access, though it is not identical to being the root user.
Use the id command to see a user's primary group ID (GID) and
supplementary GIDs:
id usernameThe /etc/group file stores all group names and their GIDs:
cat /etc/groupSystem administrators (root users) can manage groups and their GIDs using:
-
Create a group:
sudo groupadd -g [GID] [groupname] -
Modify a group's GID:
sudo groupmod -g [new_GID] [groupname]
(Use with caution, as this affects file access for group members.) -
Change a file's group:
sudo chgrp [new_group] [filename]
I hope this explanation helps you understand the concept of GID in Linux. If you have more specific questions about groups or permissions, feel free to ask.