DevToolsmith

Chmod 2775

chmod 2775 sets the permissions to rwxrwsr-x: it gives the owner and group full access, with setgid. Here is exactly what that allows on files and directories, when to use it, and the commands to apply it.

Runs 100% in your browser — nothing is uploaded

ClassreadwriteexecuteValue
owner7
group7
others5
Common:
$ chmod 2775 file.sh
$ chmod u=rwx,g=rwxs,o=rx file.sh
  • • The owner can read, write and execute.
  • • The group can read, write and execute.
  • • Everyone else can read and execute.
  • • Setgid: runs with the group’s privileges (on directories, new files inherit the group).

What chmod 2775 means

WhoDigitLettersOn a fileOn a directory
owner 7 rwx Can read, modify and run Can list files, create, delete and rename files and enter it and open files
group 7 rwx Can read, modify and run Can list files, create, delete and rename files and enter it and open files
others 5 r-x Can read and run Can list files and enter it and open files

Each digit is the sum of read (4), write (2) and execute (1), and the leading digit sets the special bits: setuid (4), setgid (2) and sticky (1). In ls -l output it looks like this:

$ ls -l
drwxrwsr-x  2 alice  staff  4096 Oct 21 10:30 example-dir
  • The owner can read, write and execute.
  • The group can read, write and execute.
  • Everyone else can read and execute.
  • Setgid: runs with the group’s privileges (on directories, new files inherit the group).

When to use 2775

  • Shared team directories
  • Web roots edited by several deploy users

With setgid on a directory, new files and subdirectories inherit the directory’s group instead of the creator’s primary group, so a team keeps working in one shared group. ls -ld shows an s in the group execute position: drwxrwsr-x.

Is chmod 2775 safe?

Yes, for shared team directories. Other users can read and execute it, but can’t change it. Don’t use it for files that contain secrets.

Commands

# One file or directory
chmod 2775 path

# Same thing in symbolic form
chmod u=rwx,g=rwxs,o=rx path

# Every directory under a tree (leaves files alone)
find /path/to/dir -type d -exec chmod 2775 {} +

# Check the result
stat -c '%a %A %n' path    # Linux
stat -f '%Lp %Sp %N' path  # macOS

Avoid chmod -R 2775 on a whole tree: it gives files and directories the same mode. The find form above changes only directories.

Other chmod values

777 · 775 · 770 · 755 · 751 · 750 · 744 · 711 · 700 · 666 · 664 · 660 · 644 · 640 · 600 · 555 · 500 · 444 · 400 · 000 · 1777 · 4755

Need a different combination? Use the Chmod Calculator.

Sources

Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.

Frequently asked questions

What does chmod 2775 mean?

chmod 2775 sets the permissions to rwxrwsr-x. The owner can read, write and execute. The group can read, write and execute. Everyone else can read and execute. Setgid: runs with the group’s privileges (on directories, new files inherit the group).

Is chmod 2775 safe?

Yes, for shared team directories. Other users can read and execute it, but can’t change it. Don’t use it for files that contain secrets.