File permissions · modechmod 755rwxr-xr-x

What chmod 755 (rwxr-xr-x) means, who is allowed to do what, and when these permissions are used: a directory, a script, a file served by a web server.

Open in the calculator
Class by classfile or directory
7
Owner
Read the contents, change and save it, run it.
5
Group
Read the contents, run it.
5
Others
Read the contents, run it.
When and why

The owner edits, everyone else reads and enters. A directory needs the x bit to be entered, a script needs it to run.

Mode
Octal755
Symbolicrwxr-xr-x
ls -l line-rwxr-xr-x
Command
chmod 755 file
01

What breaks

403 Forbidden from the web server

open() "/var/www/site/index.html" failed (13: Permission denied)

Without the x bit on a directory, nginx and apache cannot enter it: the file inside exists, yet the server returns 403. The same root cause gives «bash: ./deploy.sh: Permission denied» — a script without x does not run. 755 covers both at once.

02

Easily confused with

775rwxrwxr-x

the group writes too — right for a shared team directory, needless for site files.

chmod 775
750rwxr-x---

outsiders cannot enter at all: a directory for the owner and their group.

chmod 750
644rw-r--r--

no execution — for an ordinary file; on a directory it means «no entry».

chmod 644
03

Commands for this case

find . -type d -exec chmod 755 {} +

755 for directories recursively, and for directories only: `chmod -R 755` would make every file executable too, so files get 644 in a separate command

chmod 755 deploy.sh

make a script runnable — without x it answers «Permission denied»

Work out other permissions

The calculator opens on this mode: checkboxes, octal and symbolic notation, an ls -l line and the ready command.

Open the calculator on this modeAll common modes

Updated

«» added to favorites