chmod 775: shared folders and scripts for a group (rwxrwxr-x)

Open this example in the tool

Try it in the tool

Chmod Calculator

Translate 755 ↔ rwxr-xr-x ↔ u=rwx,g=rx,o=rx instantly.

chmod 775 is rwxrwxr-x: the owner and the group can do everything, and others can read and run but not change. It is the shared folder version of 755.

Octal      775
Symbolic   rwxrwxr-x   (ls -l: -rwxrwxr-x)
Command    chmod 775 file

  owner   7  read  write  execute
  group   7  read  write  execute
  others  5  read         execute

What it allows on a folder

A folder at 775 lets every member of its group list the contents, enter it, create files, rename them and delete files (even those created by other members, unless the sticky bit is on). That is what a team needs for a shared project, and also why the group must be small and chosen on purpose.

Typical uses

  • A project or deploy folder that a group of developers (or a CI user plus developers) updates.
  • A web application’s writable folders (cache, uploads), owned by the web server’s group.
  • Shared scripts that a team keeps in a common location.

The group has to be right

The mode is only half the story. The group that owns the folder must be the team’s group:

sudo chgrp devs /srv/project
sudo chmod 2775 /srv/project
ls -ld /srv/project        # drwxrwsr-x 2 deploy devs ...

The 2 at the start of 2775 is the setgid bit. Without it, a file that a member creates gets that member’s primary group, and the rest of the team can no longer write to it. With it, every new file and subfolder inherits devs. Combine it with umask 002 so that new files are group-writable, as explained on the 664 page.

775 instead of 777

When someone answers a “Permission denied” with chmod 777, they open the folder to every account on the system. A group-owned 775 solves the same problem for the people who need it, and only them. The reasoning is on the 777 page. If a service needs write access, add the service’s user to the group, rather than opening the folder to everyone.

Not for code that runs on the web

For the code of a web application, prefer 755 with the deploy user as the owner. If the web server’s account can write to the code, an attacker who finds a flaw can change the application. Keep 775 for the folders that really need to be written, such as uploads or caches, and keep those outside the code or without the execute right for scripts.

Check it

ls -ld folder prints the mode, owner and group. The chmod calculator accepts the four-digit form, so entering 2775 shows the setgid bit as s in the symbolic output. When a web page that depends on the folder fails, read 403 Forbidden for the checks to make.

Frequently asked questions

What does chmod 775 mean?

The owner and the group can read, write and execute (7), and everyone else can read and execute (5): rwxrwxr-x. For a folder, group members can create and delete files in it.

What is the difference between 775 and 777?

Only the last digit. 775 stops the 'others' class from writing. That one difference decides whether any account on the machine can change the folder or only members of one group.

What does 2775 mean?

The leading 2 is the setgid bit. On a folder it makes new files and subfolders inherit the folder's group, which is what a shared team folder needs. It shows as rwxrwsr-x.

Should the web server's folder be 775?

Only a folder the web server must write to, and only if the server's group owns it. For the code itself, 755 with a deploy user as the owner is safer, because an exploited application cannot rewrite its own files.

More in this reference