Unix Permissions Grant Read, Write and Execute Separately to the Owner, the Group and Everyone Else
Every file and directory on Linux and macOS has an owner, a group, and three sets of rights: what the owner may do, what members of the group may do, and what everyone else may do. Each set is read, write and execute. ls -l prints all of it in ten characters, such as -rw-------.
Reading ls -l
-rw------- 1 root root 672K Nov 23 18:15 etcd-k8s-cp-01-20261123T171508Z.tar.zst
│└┬┘└┬┘└┬┘ │ └┬─┘ └┬─┘ └┬─┘ └────┬─────┘ └─ name
│ │ │ │ │ │ │ │ └─ last modified
│ │ │ │ │ │ │ └─ size
│ │ │ │ │ │ └─ group
│ │ │ │ │ └─ owner
│ │ │ │ └─ link count
│ │ │ └─ others: --- nothing
│ │ └─ group: --- nothing
│ └─ owner: rw- read and write
└─ type: - file
- Type:
-regular file,ddirectory,lsymbolic link (alsoc/bdevices,ssockets,ppipes). - Each triplet:
rread,wwrite,xexecute,-not allowed, always in that order.
So -rw------- is a regular file that its owner, root, can read and change, and that nobody else can open at all.
Octal Notation
Each right has a value: r = 4, w = 2, x = 1. Add them per triplet and you get one digit per triplet:
| Mode | Octal | Typical use |
|---|---|---|
-rw------- |
600 |
secrets: private keys, backup bundles with CA keys, kubeconfigs |
-rw-r--r-- |
644 |
ordinary files everyone may read |
-rw-r----- |
640 |
readable by one group (e.g. a service's config) |
-rwxr-xr-x |
755 |
programs and scripts, ordinary directories |
drwx------ |
700 |
private directories: ~/.ssh, /var/backups/etcd, ~/Backups/homelab/etcd |
chmod 600 file sets the mode in octal; chmod u+x file or chmod go-rwx file changes single rights (u owner, g group, o others, a all). chown root:root file changes owner and group. stat -c '%a %U:%G %n' file prints the octal mode on Linux (stat -f '%Lp %Su:%Sg %N' on macOS).
What the Rights Mean on a Directory
A directory is a list of names, so its rights apply to the list:
r: list the names in it (ls).w: create, delete or rename entries in it (needsxtoo). Deleting a file depends on the directory'sw, not on the file's own rights.x: enter it and reach files by name (cd, opendir/file).
So a 700 directory protects everything inside it, even files with looser modes: nobody else can get past the directory. That's why the backup folders are 700 as well as their bundles 600.
Who Gets Which Triplet
The kernel picks exactly one triplet: the owner's if you're the owner, else the group's if you're in the group, else the others'. It doesn't add them up, so an owner with --- is locked out even if others have rwx.
root skips the read and write checks. That's why -rw------- root root means "root only": user leva can't read the bundle, but sudo can. It's why make etcd-pull runs sudo on the node to read bundles.
umask: the Rights New Files Don't Get
New files start from 666 (directories 777), and the umask removes rights from that:
| umask | New file | New directory |
|---|---|---|
022 (common default) |
644 |
755 |
077 |
600 |
700 |
The etcd backup script and make etcd-pull set umask 077 before creating anything, so every bundle is 600 from the moment it exists. Running chmod 600 afterwards would leave a short window where the file is readable by everyone, and a crash between the two steps would leave it that way.
Over NFS, Rights Follow Numbers, Not Names
NFS sends user and group IDs (UIDs, GIDs), not names. Root is a special case: by default an NFS server maps root on a client to an unprivileged user ("root squash"), so a client's root can't read or write everyone's files. My TrueNAS backups share sets Maproot root, which turns that off so the backup job, running as root, writes root-owned 0600 bundles. The price: root on any allowed client is root on the share, which is why the share is limited to the control plane's IP (see Kubernetes Storage Failures Usually Start on the Host or the NAS).
The media share is the opposite case: its files belong to UID 1000, every app writes as 1000, and root on a client is mapped to nobody (UID 65534). Root on a node can't even write there, because nobody is neither the owner nor in group 1000 of the 2775 folders.
Tools That Check Permissions for You
- ssh refuses a private key that group or others can read:
WARNING: UNPROTECTED PRIVATE KEY FILE!. Fix withchmod 600 ~/.ssh/id_ed25519. - Helm warns when the kubeconfig is group- or world-readable.
- A trailing
.or+after the mode (-rw-------.,-rw-------+) means an SELinux label or an ACL adds rules beyond these nine bits; on macOS,@means extended attributes.
References
- chmod(1) - symbolic and octal modes, special bits.
- umask(2) - how the mask applies to new files.
- path_resolution(7) - which triplet applies, and root's exemption.
- exports(5) -
root_squashandno_root_squashon an NFS server. - Linux CLI Cheat Sheet - everyday permission commands.
- Linux Administration MOC - hub for Linux notes.
Review cards
Flashcard What does `-rw-------` on a file owned by `root root` allow?
Root can read and write it; nobody else can open it. The other two triplets are empty.
Quiz What is `-rwxr-xr-x` in octal?
-
644 -
711 -
755 -
775
Owner rwx = 4+2+1 = 7, group and others r-x = 4+1 = 5.
Flashcard You may read and write a file but it still can't be deleted. Which permission is missing?
Write (with execute) on the directory that holds it: deleting removes a name from the directory's list, so the file's own rights don't decide.
Flashcard Why set `umask 077` at the start of a backup script instead of running `chmod 600` on each file it writes?
With the umask, files are created 600, so they are never readable by others, not even for a moment or if the script dies before a chmod.
Flashcard Why does an NFS share with root mapped to root need to be limited to specific client IPs?
Root on any allowed client becomes root on the share and can read or overwrite every file there, so only the machines that need it may mount it.