Chmod calculator
You can tick the boxes, type a number such as 755, or type letters such as rwxr-xr-x, and the other two update to match. The calculator covers read, write, and execute, but not the setuid, setgid, or sticky bits. It runs in your browser; nothing you enter is uploaded.
| Command | ||
|---|---|---|
| Same, with letters |
How the numbers work
Each digit covers one set of people: the first is the file's owner, the second its group, and the third everyone else. Read is worth 4, write 2, and execute 1, and each digit adds up the permissions that set of people gets. That gives every combination its own number from 0 to 7.
Take 755. The owner's 7 is 4 + 2 + 1, so read, write, and execute, written rwx. The group's 5 is 4 + 1, so read and execute, written r-x, and
everyone else gets the same 5. Together that's rwxr-xr-x, which is what ls -l shows after the file type character: - for a file and
d for a folder. You can paste the whole string from ls -l into the Letters field, including the ., +, or
@ it adds at the end for files with an SELinux label, an ACL, or macOS extended attributes.
Read, write, and execute on files and folders
On a file the three mean what they say: read the contents, change them, and run the file as a program. A script needs execute to run as ./deploy.sh, but not to
run as bash deploy.sh, because then bash only reads it.
On a folder, read lets you list the names inside, and execute lets you enter it and open the files in it. Write lets you create, rename, and delete entries, but only if you also have execute. So whether you can delete a file depends on the folder's write permission, not the file's own, unless the folder has the sticky bit set.
Common modes
| Number | Letters | Used for |
|---|---|---|
644 | rw-r--r-- | Ordinary files: web pages, images, config without secrets |
755 | rwxr-xr-x | Folders, scripts, and programs |
600 | rw------- | Private keys, .env files, anything with a password |
700 | rwx------ | Private folders such as ~/.ssh |
If other users can read your private key, OpenSSH refuses to use it and warns "UNPROTECTED PRIVATE KEY FILE"; chmod 600 on the key fixes that. New files usually
start as 644 and folders as 755, because the common default umask, 022, takes write away from group and others.
Avoid 777: it lets every account on the machine change or replace the file. If 777 makes a permission error go away, check who owns the file instead. Giving it the right
owner with chown and keeping 644 or 755 is the safer fix.
The fourth digit
A fourth digit in front sets three special bits that the calculator leaves out: 4 is setuid, 2 is setgid, and 1 is the sticky bit, so 4755 is 755 plus setuid.
In letters, these bits take the execute position: s for setuid or setgid, t for sticky, and a capital S or T when
execute is off. /tmp is usually 1777, drwxrwxrwt: anyone can create files there, but only the file's owner, the folder's owner or root can delete or rename one.
Running chmod
With letters, chmod can also add or remove one permission and leave the rest alone: chmod +x deploy.sh makes a script executable, and
chmod g-w notes.txt takes write away from the group. To see a file's current mode on Linux, run stat -c '%a %A' deploy.sh, which prints both
forms, such as 755 -rwxr-xr-x.
Be careful with chmod -R 755 on a folder: it makes every file inside executable too. A capital X gives execute only to folders and to files that
already have it, so this one command sets folders and executable files to 755 and every other file to 644:
chmod -R u=rwX,go=rX my-site