chmod 775
The owner and the group can do everything, others can read and execute. The mode for a directory that several people work in.
| Read (4) | Write (2) | Execute (1) | Digit | |
|---|---|---|---|---|
| Owner | 7 | |||
| Group | 7 | |||
| Others | 5 |
A program runs with the rights of the file's owner.
A program runs with the file's group. In a directory, new files get the directory's group.
In a directory, users can't delete or rename each other's files.
Owner and group can read, write and execute. Others can read and execute.
chmod 775 filechmod u=rwx,g=rwx,o=rx fileCommon values
What 775 allows
| Who | Digit | On a file | On a directory |
|---|---|---|---|
| Owner | 7 rwx | read, change and run | list, enter, add and remove files |
| Group | 7 rwx | read, change and run | list, enter, add and remove files |
| Others | 5 r-x | read and run | list and enter |
ls -l shows this mode as -rwxrwxr-x on a file and as drwxrwxr-x on a directory.
It is 755 with write permission for the group added. The owner and the members of the group can change things, everyone else can only look.
Where it belongs
A directory that several people work in: a shared project folder, or a website that both you and the deploy account have to be able to write to. Put everyone who needs access in one group and give the directory to that group:
chgrp -R developers /srv/project
chmod 775 /srv/project
Two things that make it work
New files should belong to the group too. The setgid bit on the directory takes care of that: with chmod 2775, whatever is created inside inherits the directory's group and not the group of whoever made it.
Whether those new files can be edited by the others depends on each person's umask. With 022 a new file is 644 and the rest of the group can only read it. With 002 it is 664. Systems that give every user a group of their own often set 002 for that reason.
When 755 is enough
If only one account ever writes there, the group doesn't need write permission. 775 makes sense when the group really contains people or programs that are supposed to change things.
The chmod calculator explains how the digits are built, and what setuid, setgid and the sticky bit add to them.