/etc/group is the plain-text group database of a Linux system: each line defines one local group by its name, password placeholder, numeric group identifier (GID) and list of supplementary members. Together with /etc/passwd and /etc/gshadow, the group file tells the system which groups exist and who belongs to them, which is the basis of group-based permissions in Linux.
When a process opens a file, the kernel compares the file’s group owner with the group IDs attached to the process, and those IDs come from this file at login. Editing /etc/group therefore changes who can read, write or execute group-owned files, directories and devices.
The format of /etc/group entries
Every line in /etc/group has four colon-separated fields, and the file must stay world-readable because ordinary programs such as ls need it to translate GIDs into names. A typical entry is developers:x:1050:alice,bob.
| Field | Example | Meaning |
|---|---|---|
| Group name | developers | Human-readable name, unique on the system |
| Password field | x | Placeholder; the real hash, if any, is in /etc/gshadow |
| Group ID (GID) | 1050 | Number stored in file ownership and checked by the kernel |
| Member list | alice,bob | Comma-separated supplementary members, no spaces |
The kernel never reads /etc/group directly; it works only with numeric GIDs. The name exists for people and tools, so renaming a group does not change file access, while changing its GID orphans every file that still carries the old number.
Primary and supplementary group membership
A Linux user has exactly one primary group and any number of supplementary groups, and /etc/group records only part of that picture. The primary group is stored as the fourth field of /etc/passwd, so a user is often a member of a group without appearing in its member list.
| Membership type | Stored in | Typical effect |
|---|---|---|
| Primary group | GID field of /etc/passwd | Default group owner of new files |
| Supplementary group | Member list in /etc/group | Extra access to group-owned resources |
| Group administrator | /etc/gshadow | May add or remove members with gpasswd |
| Temporary group | Set by newgrp at runtime | Changes the effective group of a shell |
Most distributions follow the user private group scheme: useradd creates a group with the same name as the user and makes it the primary group, which allows a permissive umask of 002 without exposing files to other users.
How /etc/group relates to other account files
The group file is one of several local account databases that the shadow suite keeps consistent. Knowing which file holds which data prevents the most common editing errors.
| File | Contents | Permissions |
|---|---|---|
| /etc/group | Groups, GIDs, supplementary members | 0644, readable by all |
| /etc/gshadow | Group password hashes and administrators | 0640 or 0000, root only |
| /etc/passwd | Users, UIDs, primary GIDs, shells | 0644, readable by all |
| /etc/shadow | User password hashes and aging data | 0640 or 0000, root only |
| /etc/login.defs | GID ranges and defaults for new groups | 0644, readable by all |
Lookups do not have to stop at the local file. The Name Service Switch configured in /etc/nsswitch.conf can add LDAP, SSSD or systemd-userdb sources, which is why getent group name is the reliable way to query a group, while reading /etc/group with cat shows only local entries.
Managing groups safely
Administrators should change /etc/group with dedicated tools rather than a plain editor, because the tools lock the file, update /etc/gshadow in step and validate the syntax.
- groupadd creates a group;
groupadd -rpicks a system GID, usually below 1000 as set by SYS_GID_MAX. - usermod -aG appends supplementary groups; omitting -a replaces all existing memberships.
- gpasswd -a and gpasswd -d add or remove one member without touching others.
- groupmod renames a group or changes its GID; groupdel removes it.
- vigr opens the file with locking when manual editing is unavoidable, and grpck checks consistency.
A membership change does not affect sessions that are already running, because supplementary GIDs are copied into the process credentials at login. The user must log out and in again, or start a shell with newgrp, before id shows the new group. Long-running services started by systemd likewise need a restart to pick up new supplementary groups, since their credentials were fixed when the process was launched.
Common mistakes with /etc/group
Errors in the group file usually appear as unexpected permission denials or, worse, silent over-privilege. The table below lists frequent problems and their fixes.
| Symptom | Likely cause | Fix |
|---|---|---|
| User lost all other groups | usermod -G used without -a | Re-add groups with usermod -aG |
| New group not visible to user | Session started before the change | Log in again or use newgrp |
| Files show a number instead of a group | Group deleted or GID changed | Recreate the GID or run chgrp |
| Lookup tools behave oddly | Syntax error or duplicate entry | Run grpck and edit with vigr |
| Unexpected sudo or Docker access | User in wheel, sudo or docker | Audit privileged group members |
Membership in groups such as wheel, sudo, adm, disk or docker is effectively administrative privilege, so these entries deserve regular review in any security audit. A useful habit is to compare the output of getent group against an approved list and to record every membership change in the change log, because the group file itself keeps no history of who was added or when.
The simple explanation
Think of /etc/group as the membership list of every club on a Linux computer. Each line names a club, gives it a number, and lists the people who belong to it.
Files and folders can be shared with a club. When someone tries to open a shared file, the computer checks whether that person is in the right club. Adding a name to the list grants access, and removing it takes the access away at the next login.
How it is used in practice
A small web agency runs a shared Linux server where three developers maintain the company website under /srv/site. The administrator runs groupadd webdev, which adds a new group line such as webdev:x:1201: to /etc/group, and then usermod -aG webdev for each developer, so the line becomes webdev:x:1201:anna,marek,lucia.
Next, the administrator runs chgrp -R webdev /srv/site and sets the setgid bit on the directories with chmod 2775, so new files automatically belong to webdev. After logging in again, all three developers can edit each other’s files, while other server accounts can only read them. When Marek leaves the agency, gpasswd -d marek webdev removes his write access without changing any file permissions.