What is the difference between primary groups and supplementary groups?
A user has exactly one primary group (the GID in /etc/passwd, used as the group-owner of files they create) and any number of supplementary groups (listed in /etc/group) that grant extra access.
The practical difference: the primary group decides the group ownership stamped on a brand-new file; the supplementary groups are just additional memberships the kernel checks when deciding group permissions. For checking file access the two kinds are treated identically — if you're in the group at all, you get group permissions.
Primary Group:
- Stored in
/etc/passwd(4th field) - Created automatically with same name as user
- Used for new files created by user
- Visible in
ls -loutput
Supplementary Groups:
- Listed in
/etc/group - Provide additional permissions
- Can belong to many groups
Example:
labstudent:x:1004:1004::/home/labstudent:/bin/bash
│ │
│ └── GID 1004 (primary group)
└── UID 1004
View groups:
id labstudent
# uid=1004(labstudent) gid=1004(labstudent) groups=1004(labstudent),10(wheel)
/etc/group format:
groupname:x:GID:members
wheel:x:10:packer,sysmgmt,florian,labstudent,labadmin
Key insight: For file permissions, primary and supplementary groups are treated equally - if you're in the group, you get group permissions.