chmod 2775 (rwxrwsr-x) explained

The owner can read, write and execute; the group can read, write and execute; others can read and execute.

Octal
2775
Symbolic
rwxrwsr-x
ls -l shows
drwxrwsr-x

Who can do what

Class Read (4) Write (2) Execute (1) On a directory
Owner (u)YesYesYesList the files. Enter it and open files inside. Create, rename and delete files.
Group (g)YesYesYesList the files. Enter it and open files inside. Create, rename and delete files.
Others (o)YesNoYesList 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/file

To 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.

Work out any mode in the Chmod Calculator