Linux Users, Groups, and Permissions
Linux identifies people and services with numeric user and group IDs. File ownership and permission rules use those IDs to decide which processes may read, change, execute, or traverse filesystem objects.
itLinux | OpenSkills.info
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Don't Panic
Don't Panic — Linux Users, Groups, and Permissions
Linux access control is a small tribunal conducted at great speed. A process arrives carrying numeric user and group IDs. A file or directory presents its numeric owner, group, and mode. The kernel compares them and permits or denies the requested operation. The familiar names are there so humans can cope; the numbers are what the filesystem keeps when humans are elsewhere having a meeting.
The crucial idea is that Linux chooses one ordinary permission class. If the process's effective user ID owns the object, owner bits apply. Otherwise a matching group can select group bits. Otherwise, other bits apply. They do not combine into a generous buffet. An owner denied by owner bits does not borrow group access, however politely it asks.
Directories are the usual ambush. Search permission is directory execute permission: it allows a name to be resolved through that directory. Read lists names. Write changes entries. So deleting a file depends on its containing directory, while changing file contents depends on the file. A mode that looks like a tiny row of letters is therefore a map of several different operations wearing a trench coat.
Groups make shared access manageable. Give a project directory a project group, grant the group the required directory access, and set the directory's set-group-ID bit when new children must keep that group. New group membership does not alter credentials already carried by a running shell or service, so begin a new authenticated session before declaring the change mysteriously ineffective.
When access fails, start with the current process and numeric ownership. Then trace every parent directory, the selected mode class, any ACL mask, mount state, and mandatory security policy. An ACL can grant named-user or named-group entries, but its mask can limit what those entries actually deliver. A permissive-looking file is not a guarantee; Linux has several more opportunities to say no.
For the detailed map, read the Intro and then the Slides. Use the Cheatsheet beside a terminal for mode values and diagnostic order. The Practice Reference and exercise keep the experiment inside a temporary directory, where no production path is harmed in the making of a useful mistake. The Timeline explains how capabilities and user namespaces made the old all-powerful root story less tidy. It was never really tidy; it merely had fewer chapters.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://cdn.kernel.org/doc/html/latest/security/credentials.html
Supports
- Processes carry real, effective, saved, and filesystem user and group IDs plus supplementary groups
- Linux objects carry UIDs and GIDs while tasks carry a subjective credential context
- Capabilities provide distinct units of privilege and security modules can add controls
- File markings can include UID, GID, mode, ACL, security label, set-ID bits, and file capabilities
- https://www.gnu.org/software/coreutils/manual/coreutils.html
Supports
- Files have owner, group, and mode attributes
- chmod, chown, chgrp, id, and stat inspect or change relevant attributes
- Symbolic and numeric mode notation used in the course
- https://www.gnu.org/software/coreutils/manual/html_node/Mode-Structure.html
Supports
- Owner, group, and other are the three ordinary permission classes
- Read, write, and execute have file and directory-specific meanings
- Mode bits include set-user-ID, set-group-ID, and sticky components
- https://www.gnu.org/software/coreutils/manual/html_node/Setting-Permissions.html
Supports
- Symbolic modes use a user class, an add-remove-set operation, and permission letters
- Equals replaces, plus adds, and minus removes permissions in a selected class
- https://man7.org/linux/man-pages/man5/passwd.5.html
Supports
- Local account entries map names to UID, primary GID, home directory, and login shell
- Shadow-password systems place an x in passwd and hashes in a restricted shadow file
- Root has UID zero and supplementary groups are defined separately
- https://man7.org/linux/man-pages/man5/group.5.html
Supports
- Local group entries contain a group name, numeric GID, and member list
- https://man7.org/linux/man-pages/man8/useradd.8.html
Supports
- useradd creates accounts from command options and system defaults
- Primary and supplementary group options have distinct roles
- Reusing a UID connects multiple login names to the same ownership and permission identity
- https://man7.org/linux/man-pages/man1/id.1.html
Supports
- id prints real and effective user and group IDs and supplementary groups
- https://man7.org/linux/man-pages/man1/getent.1.html
Supports
- getent queries databases supported by the Name Service Switch
- passwd and group queries resolve through configured sources
- https://man7.org/linux/man-pages/man1/namei.1.html
Supports
- namei follows a pathname and long-list mode shows the mode and owners of each component
- https://man7.org/linux/man-pages/man8/mount.8.html
Supports
- Read-only mounts restrict writes
- The nosuid option suppresses interpretation of set-user-ID and set-group-ID bits
- https://www.gnu.org/software/libc/manual/html_node/Name-Service-Switch.html
Supports
- Name Service Switch configuration selects databases for user and group lookups
- Identity resolution can use sources beyond local files
- https://man7.org/linux/man-pages/man2/chmod.2.html
Supports
- chmod changes mode bits when the effective UID owns the file or the process has required privilege
- Directory execute means search and special mode bits have file or directory effects
- Linux may clear set-ID bits after an unprivileged write
- fchmodat appeared in Linux 2.6.16
- https://man7.org/linux/man-pages/man2/umask.2.html
Supports
- Umask removes bits from the mode requested during object creation
- A default ACL can determine inherited permissions during creation
- https://man7.org/linux/man-pages/man5/acl.5.html
Supports
- ACLs add named user and group entries to the ordinary owner-group-other model
- The ACL mask limits named users, named groups, and the owning group entry
- Default directory ACLs participate in permission inheritance
- Access checks select the owner, named-user, group, or other path without class fallthrough
- https://man7.org/linux/man-pages/man7/capabilities.7.html
Supports
- Linux 2.2 divided superuser privilege into capabilities
- Linux 2.6.24 completed file-capability support
- Linux 2.6.25 made the bounding set per-thread
- Linux 4.3 added ambient capabilities and Linux 4.14 added namespaced file capabilities
- Linux 5.12 added CAP_SETFCAP to the conditions for mapping user ID zero in a user namespace
- https://man7.org/linux/man-pages/man7/user_namespaces.7.html
Supports
- User namespaces isolate user and group ID number spaces and capability scope
- Linux 3.8 allowed unprivileged processes to create user namespaces
- UID and GID mapping files relate namespace identities to identities outside the namespace
- https://www.kernel.org/pub/linux/libs/security/linux-privs/old/doc/linux-privs.html/linux-privs.html
Supports
- The April 1997 Linux-Privs draft described capabilities, ACLs, and process credentials
- https://www.kernel.org/pub/linux/kernel/v2.2/
Supports
- Linux 2.2.0 was published in January 1999
- https://www.kernel.org/pub/linux/kernel/v2.6/
Supports
- Release archive dates for Linux 2.6.16, 2.6.24, and 2.6.25
- https://www.kernel.org/pub/linux/kernel/v3.x/
Supports
- Linux 3.8 release archive date in February 2013
- https://www.kernel.org/pub/linux/kernel/v4.x/
Supports
- Linux 4.3 and 4.14 release archive dates in 2015 and 2017
- https://www.kernel.org/pub/linux/kernel/v5.x/
Supports
- Linux 5.12 release archive date in April 2021
- https://github.com/sindresorhus/awesome
Supports
- The master Awesome index includes an IAM list and routes Linux administration discovery to curated lists
- https://github.com/awesome-foss/awesome-sysadmin
Supports
- The curated sysadmin list includes FreeIPA, OpenLDAP, LLDAP, and LDAP Account Manager in identity-management sections
- https://www.freeipa.org/page/Documentation
Supports
- FreeIPA documents centralized Linux identity, authentication, users, groups, and host access policy
- https://www.openldap.org/doc/admin26/
Supports
- The OpenLDAP guide covers building, configuring, and operating directory services
- LDAP directories can centrally manage user authentication and user or system groups
- https://www.ldap-account-manager.org/static/doc/manual/index.html
Supports
- LDAP Account Manager documents Unix users, Unix groups, shadow attributes, and SSH public keys
- https://github.com/lldap/lldap
Supports
- LLDAP provides an LDAP server and web interface aimed at compact identity-management deployments
- https://access.redhat.com/solutions/225283
Supports
- A default ACL on a target directory can appear permissive while access fails because a parent directory denies traversal
