chmod 775
chmod 775 sets rwxrwxr-x: the owner and every member of the file's group get full read, write and execute access, and everyone else can read and execute (enter a directory) but not change anything.
Permission matrix
| Who | Read (4) | Write (2) | Execute (1) | Digit |
|---|---|---|---|---|
| Owner (u) | Yes | Yes | Yes | 7 |
| Group (g) | Yes | Yes | Yes | 7 |
| Others (o) | Yes | No | Yes | 5 |
Execute means different things by type. On a file it lets the kernel run it as a program. On a directory it is search permission: entering it (cd) and reaching the files inside by name. Read on a directory only lists names.
| Who | On a file | On a directory |
|---|---|---|
| Owner (u) | Read, modify and run | List, enter, create, delete and rename entries |
| Group (g) | Read, modify and run | List, enter, create, delete and rename entries |
| Others (o) | Read and run | List, enter and open entries |
Facts
| Octal | 775 (0775) |
|---|---|
| Symbolic | rwxrwxr-x |
| ls -l, file | -rwxrwxr-x |
| ls -l, directory | drwxrwxr-x |
| Equivalent symbolic command | chmod ug=rwx,o=rx |
| Default umask that creates it | umask 002 for new directories |
| How Git records a file with it | 100755 (executable) |
| Special bits | None |
When to use it
- Project or deploy directories that several people edit, all in one group (for example a deploy group containing you and the CI user).
- Directories the web server must write to when it shares a group with your user, the arrangement the WordPress file permissions guide describes as 775 for folders and 664 for files.
- It is what mkdir produces under umask 002, the default for regular users on distributions that give each user a private group.
When not to use it
- When the group is broad (users, staff, a group every account belongs to): group write then means everyone can write.
- On regular files that are not programs. Use 664 so data files are not marked executable.
- Without the setgid bit on shared directories: new files get the creator's primary group, and colleagues lose write access. Use 2775 so new files inherit the directory's group.
Commands
sudo chmod 775 /srv/projects/site
sudo chmod ug=rwx,o=rx /srv/projects/site # same resultstat -c '%a %A %n' /srv/projects/site # Linux (GNU stat): 775 drwxrwxr-x
stat -f '%Lp %Sp %N' /srv/projects/site # macOS and BSDApplying it to a whole tree
chmod -R would put the same mode on files and directories alike. Set directories to 775 and files to 664 separately:
sudo find /srv/projects/site -type d -exec chmod 775 {} +
sudo find /srv/projects/site -type f -exec chmod 664 {} +Or in one pass with a capital X, which adds execute only to directories and to files that already had it: chmod -R ug=rwX,o=rX /srv/projects/site.
Git and the execute bit
Git stores only one permission fact per file: 100755 if the owner execute bit is set, 100644 otherwise. A file with this mode is committed as 100755; the group and others bits never reach the repository. On Windows, or where core.fileMode is false, set the bit with git update-index --chmod=+x.
Frequently asked questions
- What is the difference between 755 and 775?
- Only the group digit. With 755 the group can read and enter; with 775 the group can also create, rename and delete files in the directory. Others get r-x in both.
- Why do my new directories come out as 775?
- Your umask is 002. mkdir asks for 777 and the umask removes write for others, giving 775. New files get 664 the same way, because files start from 666.
- Is 775 safe for a website?
- It is acceptable when the group contains only you and the web server account. Visitors never see Unix permissions; the risk is other local accounts or processes in the same group.
Last reviewed by Arielton Oberek.