Who can do what
| Class | Read (4) | Write (2) | Execute (1) | On a directory |
|---|---|---|---|---|
| Owner (u) | Yes | No | No | List the file names, but not open them. |
| Group (g) | Yes | No | No | List the file names, but not open them. |
| Others (o) | Yes | No | No | List the file names, but not open them. |
When to use chmod 444
Lets everyone read the file and nobody write or execute it, not even the owner.
Makes a file read-only for everyone, a simple guard against accidental edits. The owner and root can still change the mode.
Commands
Set the mode with octal digits, or with the equivalent symbolic form:
chmod 444 path/to/file
chmod u=r,g=r,o=r path/to/fileTo apply it to every directory below a folder (and not to the files), combine it with find:
find path/to/folder -type d -exec chmod 444 {} +chmod -R 444 changes files and directories alike, which is rarely what you want: directories usually need execute, regular files usually should not have it.