Chmod calculator

Tick who may read, write and execute a file, or type a number such as 755. You get the octal and symbolic forms and the command to run, with what the common values are for.

Who may do what
ReadWriteExecute
Owner 7
Group 5
Others 5
Special bits
Chmod number 755 rwxr-xr-x
Letters
rwxr-xr-x
ls -l, file
-rwxr-xr-x
ls -l, folder
drwxr-xr-x
With the number
chmod 755 file
With letters
chmod u=rwx,g=rx,o=rx file

On a VPS you set the permissions yourself: you get root access and can give each site its own Linux user. From €3.02 a month today, among 2,226 servers.

Common permissions

ModeLettersUse
rwxr-xr-xFolders, scripts and programs: the owner changes them, everyone may read and run them.
rw-r--r--Ordinary files of a website: the owner writes, everyone reads.
rwxr-x---Like 755, but users outside the group get nothing.
rw-r-----Config files the web server's group must read, such as wp-config.php.
rwx------Private folders and scripts, such as ~/.ssh.
rw-------Secrets only the owner reads and writes: SSH private keys, .env files.
r--------Read-only for the owner, such as a key that should never change.
rwxrwxrwxEveryone may read, write and run. Avoid it: any user or hacked script on the server can change the file.

Permissions for a website

Folders 755 and files 644 suit most sites: the user that deploys writes, the web server reads. Run these in the site's folder, then make secrets such as wp-config.php or .env 640 or 600.

bash
find /var/www/example.com -type d -exec chmod 755 {} +
find /var/www/example.com -type f -exec chmod 644 {} +
chmod 640 /var/www/example.com/wp-config.php

Works in your browser: nothing you type is sent anywhere.

How it is calculated

Every file has three sets of permissions: for its owner, for its group and for everyone else. Each set has three bits, read (4), write (2) and execute (1), and one octal digit is their sum.

digit = read 4 + write 2 + execute 1
mode = owner, group, others
755 = rwx (4+2+1) r-x (4+1) r-x (4+1)
644 = rw- (4+2) r-- (4) r-- (4)

A fourth digit in front holds the special bits: setuid 4, setgid 2 and sticky 1. ls shows them in the execute places, s for setuid or setgid and t for sticky, in capitals when the execute bit underneath is off. On a folder, execute is the right to enter it, so folders need x where plain files do not.

Example

chmod 640 wp-config.php: the owner reads and writes (6 = 4 + 2), the group reads (4) and others get nothing (0). ls -l then shows -rw-r-----, and the web server can read the file only if it is in the file's group.

Questions

What does chmod 755 mean?

The owner may read, write and execute (7), and the group and everyone else may read and execute (5 each). ls -l shows it as rwxr-xr-x. It is the usual mode for folders and for scripts and programs others need to run.

What is the difference between 644 and 755?

Only the execute bit. 644 (rw-r--r--) lets the owner write and everyone read; 755 also lets everyone execute. Plain files such as HTML, images and PHP files need 644, folders and scripts that run on their own need 755.

Why should I not use chmod 777?

777 lets every user and process on the server change the file. If one site or plugin is hacked, the attacker can rewrite everything that is 777. A permission error is better fixed by giving the file to the right user with chown, or by adding the web server to the file's group.

How do I change permissions for all files in a folder?

chmod -R 755 folder changes everything inside, files included, which makes every file executable. To set folders and files apart, use find: find folder -type d -exec chmod 755 {} + for folders and find folder -type f -exec chmod 644 {} + for files.