Skip to content

Latest commit

 

History

History
72 lines (50 loc) · 2.25 KB

File metadata and controls

72 lines (50 loc) · 2.25 KB

Understanding GID in Linux

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 Role of GID

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 Number Ranges


GID Range Group Type Typical Use


0 - 99 Reserved for kernel System-level processes

100 - 999 System groups Groups for system services/admin

1000 - 59999 Regular user groups Groups for standard user accounts

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.

📜 How to View GIDs

Check a user's GIDs

Use the id command to see a user's primary group ID (GID) and supplementary GIDs:

id username

List all groups

The /etc/group file stores all group names and their GIDs:

cat /etc/group

⚙️ Managing GIDs

System 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.