Who can do what
| Class | Read (4) | Write (2) | Execute (1) | On a directory |
|---|---|---|---|---|
| Owner (u) | Yes | Yes | No | List the file names, but not open them. |
| Group (g) | Yes | Yes | 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 664
Lets the owner and the group read and write, and everyone else read.
The usual mode for files in a shared group directory: teammates can edit, others can read. It is what new files get with a umask of 002.
Commands
Set the mode with octal digits, or with the equivalent symbolic form:
chmod 664 path/to/file
chmod u=rw,g=rw,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 664 {} +chmod -R 664 changes files and directories alike, which is rarely what you want: directories usually need execute, regular files usually should not have it.