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 | No | Yes | List the files. Enter it and open files inside. |
When to use chmod 2775
Gives the owner and the group full access and others read and execute, plus the setgid bit: new files and subdirectories inherit the directory's group.
The standard setup for team directories. With setgid, everything created inside belongs to the shared group, so teammates keep being able to edit it.
Special bits
- Setgid (2): on a directory, new files and subdirectories inherit its group; on an executable, it runs with the file's group.
Commands
Set the mode with octal digits, or with the equivalent symbolic form:
chmod 2775 path/to/file
chmod u=rwx,g=rwx,o=rx,g+s 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 2775 {} +chmod -R 2775 changes files and directories alike, which is rarely what you want: directories usually need execute, regular files usually should not have it.