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 | Yes | Yes | List the files. Enter it and open files inside. Create, rename and delete files. |
| Others (o) | Yes | Yes | Yes | List the files. Enter it and open files inside. Create, rename and delete files. |
When to use chmod 777
Gives everyone full access: any user on the system can read, change and run the file, or create and delete files in the directory.
Almost never the right answer. It is the usual "fix" for a permission error and a common security hole: any account or compromised process can modify the file. Find out which user needs access and give it to that user or group instead, typically with 755 or 775.
Commands
Set the mode with octal digits, or with the equivalent symbolic form:
chmod 777 path/to/file
chmod u=rwx,g=rwx,o=rwx 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 777 {} +chmod -R 777 changes files and directories alike, which is rarely what you want: directories usually need execute, regular files usually should not have it.