Who can do what
| Class | Read (4) | Write (2) | Execute (1) | On a directory |
|---|---|---|---|---|
| Owner (u) | Yes | Yes | Yes | List the files. Enter it and open files inside. Create, rename and delete files. |
| Group (g) | Yes | No | Yes | List the files. Enter it and open files inside. |
| Others (o) | Yes | No | Yes | List the files. Enter it and open files inside. |
When to use chmod 755
Gives the owner full access and everyone else read and execute. It is the standard mode for directories and for executable files: scripts, binaries and the folders of a web site.
Safe for public content. Others can read and run but not change anything. For regular files that are not programs, 644 is enough.
Commands
Set the mode with octal digits, or with the equivalent symbolic form:
chmod 755 path/to/file
chmod u=rwx,g=rx,o=rx 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 755 {} +chmod -R 755 changes files and directories alike, which is rarely what you want: directories usually need execute, regular files usually should not have it.