What it means
chmod 775 gives the owner and the group read, write and execute permission, and gives everyone else read and execute. In ls -l it shows as drwxrwxr-x for a directory or -rwxrwxr-x for a file.
| Who | Digit | Read | Write | Execute | Symbolic |
|---|---|---|---|---|---|
| Owner (u) | 7 | yes | yes | yes | rwx |
| Group (g) | 7 | yes | yes | yes | rwx |
| Others (o) | 5 | yes | no | yes | r-x |
The symbolic equivalent:
chmod ug=rwx,o=rx /srv/shared
It's chmod 755 plus write for the group.
On a directory
The owner and every group member can create, delete and rename files in the directory. Others can list and enter it, and read files whose own modes allow it, but can't change anything. With umask 002, mkdir creates directories as 775 by default.
Group write on a directory means a group member can delete or rename any file in it, including files owned by someone else. Write permission on the file itself doesn't matter for deletion. If that's a problem, add the sticky bit (chmod +t, mode 1775) so only a file's owner can remove it.
On a file
On a file, 775 means the owner and group can edit and run it, and others can read and run it. Use it for scripts a team maintains together. For plain data files, chmod 664 is the file equivalent without the execute bit.
Typical uses
- Shared project or deploy directories where several people in one group push changes.
- Writable app directories like
storage/,cache/oruploads/, owned by the deploy user with the web server's group, so both can write:
sudo chown -R deploy:www-data /var/www/app/storage
sudo find /var/www/app/storage -type d -exec chmod 2775 {} +
sudo find /var/www/app/storage -type f -exec chmod 664 {} +
The leading 2 (setgid) makes new files and subdirectories inherit the www-data group. Without it, files created by deploy get deploy's primary group, and the web server can no longer write them. See chmod 2775.
Make the umask match
775 directories only stay useful if new files get group write too. Each user and service that writes there needs umask 002:
umask 002 # in ~/.profile or a deploy script
For a systemd service, set UMask=0002 in its unit. PHP-FPM uses the umask of its service, so set it there rather than in PHP code.
775 vs 777
775 is the right answer to "the web server can't write to this folder" in most cases. 777 also gives write to every other account on the machine, which you almost never want. If 775 doesn't work, the cause is usually ownership: the server's user isn't in the directory's group. Check with ls -ld dir and id www-data, then fix the group instead of opening the mode further.
Recursive pitfalls
chmod -R 775 makes every file executable and group-writable. Code files should usually not be writable by the web server's group, or a bug in the app can let it rewrite itself. Limit 775 to the directories that need it and apply modes separately for files and directories, or use X:
chmod -R ug=rwX,o=rX /srv/shared
Security notes
Everyone in the group has full control over the directory's contents, so check membership (getent group www-data). If others shouldn't read anything, drop to 770.
Related modes
- chmod 755: only the owner can write.
- chmod 2775: the same, with group inheritance.
- chmod 664: the matching file mode.
- chmod 777: too open.
Try 775, 2775 and 770 side by side in the chmod calculator.