chmod 755: what it means and when to use it
chmod 755 lets the owner read, write and execute, while the group and everyone else can read and execute but not change anything.
755
rwxr-xr-x
| Who | Digit | Read | Write | Execute |
|---|---|---|---|---|
| Owner | 7 |
Yes | Yes | Yes |
| Group | 5 |
Yes | No | Yes |
| Everyone else | 5 |
Yes | No | Yes |
How chmod 755 works
Each digit is a total: read is 4, write is 2 and execute is 1. The first 7 is 4 + 2 + 1 for the owner, and each 5 is 4 + 1, for the group and for everyone else.
755 is the standard permission for directories, and for scripts or programs that other users need to run. On a directory, execute means permission to enter it and reach the files inside, which is why web server folders are usually 755 while the files in them are 644.
Where 755 belongs
- Directories on a web server
- Shell scripts and programs any user may run
- The public web folder on shared hosting
The command
Both of these set exactly the same permissions. The number is shorter; the letters are easier to read back later.
chmod 755 filename
chmod u=rwx,g=rx,o=rx filename
755 is not for private files: anyone with an account on the machine can read them.