Breakdown
| Class | Digit | Symbolic | Read | Write | Execute |
|---|---|---|---|---|---|
| Owner (u) | 4 | r-- | ✔ | — | — |
| Group (g) | 0 | --- | — | — | — |
| Others (o) | 1 | --x | — | — | ✔ |
owner 4 = 4 · group 0 = 0 · others 1 = 1
Commands
chmod 401 file.txt
chmod u=r,g=,o=x file.txt # same thing, symbolic
chmod -R 401 folder/ # recursive (careful: applies to files and directories)
find folder -type d -exec chmod 401 {} + # only directories
Applied to a directory
- Owner (u): can list names, cannot create or delete entries, cannot enter.
- Group (g): cannot list names, cannot create or delete entries, cannot enter.
- Others (o): cannot list names, cannot create or delete entries, can enter (cd) and access files.
Things to know
- The owner cannot write. To edit the file you must first add write permission (or use root).
- Execute without read: on a directory this allows entering known paths without listing contents; a script cannot run this way (it must be read), but a compiled binary can.