ChmodCalc

chmod 755 — rwxr-xr-x

The mode you want on a directory and on an installed executable: the owner can change it, everybody else can use it. The calculator starts on 755 applied to a directory — flip the boxes to see what each bit costs you.

chmod — directory mode
whoreadwriteexecutedigit
Owner7
Group5
Others5
special bits — the fourth digit

ls -l → drwxr-xr-x

chmod 755 /var/www/html
chmod u=rwx,g=rx,o=rx /var/www/html

Absolute symbolic form — identical result, and the only form that can name the setuid, setgid and sticky bits.

what 755 grants on this directory

  • Ownerrwxlist the names inside, create, delete and rename entries and enter it and reach a known name inside
  • Groupr-xlist the names inside and enter it and reach a known name inside
  • Othersr-xlist the names inside and enter it and reach a known name inside

programs that refuse this mode

None of the directory rules indexed on this site rejects 755.

The arithmetic, once

7 is 4+2+1, so the owner gets read, write and execute. 5 is 4+1, so the group and everyone else get read and execute but not write. Written out:

755 decomposed. Rendered from the same functions as the calculator above.
ClassDigitBitsSum
Owner7rwx4 + 2 + 1
Group5r-x4 + 1
Others5r-x4 + 1

The full ls -l field for a directory at this mode is drwxr-xr-x, and the absolute symbolic argument that produces it is u=rwx,g=rx,o=rx.

What the last digit really buys

755's third digit is 5, and the interesting question is what the alternatives would have done. Below is every value that digit could take on a directory whose first two digits stay at 75, and what an account that is neither the owner nor in the group can then do. The four capability columns are computed straight from the bits, with nothing described by hand, which is why the row for 6 disagrees with intuition:

A directory at mode 75d, seen by a user in the "others" class. "Enter" means resolve a name inside it; "create / delete" means add or remove an entry.
Mode Others List names Enter Read a known file inside Create / delete
750 --- no no no no
751 --x no yes yes no
752 -w- no no no no
753 -wx no yes yes yes
754 r-- yes no no no
755 r-x yes yes yes no
756 rw- yes no no no
757 rwx yes yes yes yes

Read the 754 row and the 756 row together. 754 lets an outsider run ls and get a list of names, then fails on every single one of them, because reading a directory and reaching into it are separate rights. 756 adds the write bit and changes nothing at all: creating an entry requires resolving the directory first, and that needs the search bit which 6 does not have. Only the odd values — 1, 3, 5, 7 — do anything useful for a directory, which is why 64 of the 512 three-digit modes leave a directory enterable by all three classes.

755 on a file is a different decision

On a regular file the execute bit means "run this as a program", and it is worth being deliberate about handing that to everyone. Three cases where 755 is right on a file: a binary installed into /usr/local/bin, a wrapper script that any user is meant to invoke, and a CGI script the web server executes as an unprivileged user. One case where it is wrong: a deployment script that only your CI user should run, which wants 700 instead.

A static file served by nginx or Apache never needs an execute bit. The server opens and reads it; nothing is executed. Adding x to your HTML does not make it load faster or work better — it just widens what an attacker who finds a file-upload bug can do. That is the argument for 644 on content.

Applying 755 to a whole tree without wrecking it

chmod -R 755 /var/www/html applies one mode to files and directories alike. Directories come out correct. Files come out executable, which is not what you asked for and not what any static site needs. Split the tree by type instead:

find /var/www/html -type d -exec chmod 755 {} +
find /var/www/html -type f -exec chmod 644 {} +

The + at the end batches paths into as few chmod invocations as possible instead of one per file, which on a large tree is the difference between a second and a minute. If you would rather have one command, capital X does the same job: chmod -R u=rwX,g=rX,o=rX /var/www/html sets the execute bit on directories and on files that already had one, and leaves plain files alone.

The trap to avoid entirely is the inverse. chmod -R 644 /var/www/html takes the search bit off every directory, and once a directory has no execute bit you cannot reach anything inside it — including to fix it, unless you are root or the owner and can chmod the directory itself back. Recovering from that means walking the tree from the top with find, which is exactly the tool you should have used first.

When 755 does not fix your error

755 solves "the server cannot enter this directory". It does not solve an ownership problem, and it does not solve a configuration problem. These two rows from the error index are worth reading before you escalate to 777:

The Apache pair: one is a mode problem, one is not. Both were read from the server's own source.
What you see Where it comes from Fires on Fix
access to /index.html denied (filesystem path '/var/www/html/index.html') because search permissions are missing on a component of the path

Apache HTTP Server · error_log, tagged AH00035

shown for mode 750 on a directory on the path to the document root

verbatim format string: access to %s denied (filesystem path '%s') because search permissions are missing on a component of the path

Apache HTTP Server — server/request.c · ap_directory_walk(), APLOGNO(00035)

APR_STATUS_IS_EACCES(rv) inside ap_directory_walk() — a branch on the errno the kernel returned while resolving a component, not an expression over st_mode

described, not quoted — the message is not guarded by one expression

2048 of the 4096 modes fire it.

Assumes that the Apache worker user is neither the owner nor in the owning group, so it is judged by the "others" digit. If the worker is in the group, read the group digit instead.

chmod 755 /var/www/html

least-privilege mode 755

client denied by server configuration: /var/www/html/members/report.pdf

Apache HTTP Server · error_log, tagged AH01630

shown for mode 644 on not a file mode at all

verbatim format string: client denied by server configuration: %s%s

Apache HTTP Server — modules/aaa/mod_authz_core.c · authorize_user_core(), APLOGNO(01630)

the AUTHZ_DENIED / AUTHZ_NEUTRAL branch of authorize_user_core() — a control-flow branch on the authorisation result, with no mode test anywhere in it

described, not quoted — the message is not guarded by one expression

No mode fires this — chmod cannot change the outcome.

edit the Require directive — no chmod will change this

httpd-search-permissions — Apache names the failing URI and the filesystem path separately, which is the fastest way to see that a parent directory is at fault when you had been staring at the file you were trying to serve.

httpd-authz-denied — If your error line says "client denied by server configuration", stop changing modes and read the <Directory> block.

## Questions people actually ask

What does chmod 755 do?

It sets the mode to rwxr-xr-x. The owner gets read, write and execute; the group and everyone else get read and execute but not write. On a directory that means the owner can add and remove entries while everybody else can list the directory and enter it. On a file it means everybody can run it and only the owner can change it.

Is 755 safe?

It is safe in the sense that nobody but the owner can modify the target, which is the property that matters for a web root or an installed script. It is not private: every account on the machine can read the contents and, for a directory, see the names inside. If the target holds credentials, 755 is the wrong mode and 600 or 700 is the right one. The distinction is confidentiality versus integrity — 755 protects integrity only.

Should directories be 755 and files 644?

As a default, yes, and for a reason worth understanding, not memorising: a directory needs the execute bit because on a directory execute means search — the right to resolve a name inside it. A regular file served by a web server needs no execute bit at all, because the server reads it and never runs it. That asymmetry is why a single recursive mode is always wrong for one of the two, and why the two find commands below exist.

Why did chmod -R 755 break my site?

It probably did not break it so much as make every file executable, which is untidy but not fatal. The genuinely destructive mirror image is chmod -R 644, which strips the search bit from every directory and makes the tree unreachable. If your site broke after -R 755, look instead at what else changed: an executable-looking upload directory can trip a server configuration that refuses to serve executable files, and some deployment tooling treats a mode change as a content change.

What is 755 in symbolic notation?

rwxr-xr-x as ls -l prints it, or u=rwx,g=rx,o=rx as an absolute chmod argument. If the file is currently 644, the relative form that gets you there is a+x — and that form is the safer one on a file you did not create, because it changes only the execute bits and leaves everything else as it was.

Does 755 make a shell script runnable by cron?

It makes the script executable by everyone, so yes for the execute bit itself. But a cron job has two files involved and people fix the wrong one: the script needs an execute bit, while the crontab file in the spool directory must not have one. cronie rejects a crontab whose owner-execute bit is set, so chmod 700 on a crontab file silently disables it. That check is in the error index.

elsewhere on this site

  • The chmod calculator itself — all 512 three-digit modes in one table.
  • chmod 644 — The static-file mode, and why adding an execute bit to it buys nothing.
  • chmod 777 — What 777 actually grants, which errors it does not fix, and the sticky-bit alternative.

other tools we run