Breakdown
| Class | Digit | Symbolic | Read | Write | Execute |
|---|---|---|---|---|---|
| Owner (u) | 6 | rw- | ✔ | ✔ | — |
| Group (g) | 7 | rwx | ✔ | ✔ | ✔ |
| Others (o) | 4 | r-- | ✔ | — | — |
owner 6 = 4 + 2 · group 7 = 4 + 2 + 1 · others 4 = 4
Commands
chmod 674 file.txt
chmod u=rw,g=rwx,o=r file.txt # same thing, symbolic
chmod -R 674 folder/ # recursive (careful: applies to files and directories)
find folder -type d -exec chmod 674 {} + # only directories
Applied to a directory
- Owner (u): can list names, cannot create or delete entries, cannot enter.
- Group (g): can list names, can create/delete entries, can enter (cd) and access files.
- Others (o): can list names, cannot create or delete entries, cannot enter.
Things to know
- The group can modify the file, so make sure the group contains only trusted users.
- Readable by everyone: do not use this for secrets such as private keys or
.envfiles; SSH refuses keys that others can read.