Chmod calculator for Linux file permissions
Tick who may read, write and execute, or type a mode like 755 or rwxr-xr-x, and the calculator fills in the rest: the octal number, the letters ls -l shows and the chmod command to copy. Setuid, setgid and the sticky bit are covered too.
- Command
-- Symbolic command
-- Owner
- -
- Group
- -
- Others
- -
- Special bits
- -
What 755, 644, 600 and 777 mean
Each digit is one group of people: the first is the file's owner, the second its group, the third everyone else. 755 lets the owner read, write and execute, and lets everyone else read and execute. 644 lets the owner read and write, and everyone else only read. 600 keeps the file to its owner. 777 opens it to every user on the system.
For SSH, the ssh manual says private keys should be readable by you and not accessible by others, so 600 (or 400), and recommends that ~/.ssh itself is not accessible by others, so 700. ssh ignores a private key that other users can read.
| Mode | ls -l | Who can do what | Typical use |
|---|---|---|---|
| 755 | rwxr-xr-x | Owner can do everything; group and others can read and execute. | Directories, scripts and programs. The usual mode for a web root folder. |
| 644 | rw-r--r-- | Owner can read and write; group and others can only read. | Ordinary files: web pages, images, configuration that is not secret. |
| 600 | rw------- | Owner can read and write; nobody else can do anything. | Private files such as SSH private keys and files with passwords. |
| 700 | rwx------ | Owner can do everything; nobody else can do anything. | Private directories such as ~/.ssh, and scripts only you run. |
| 775 | rwxrwxr-x | Owner and group can do everything; others can read and execute. | Directories a team shares through a common group. |
| 664 | rw-rw-r-- | Owner and group can read and write; others can only read. | Files a team edits through a common group. |
| 400 | r-------- | Owner can only read; nobody else can do anything. | Keys and certificates that should never change. |
| 777 | rwxrwxrwx | Everyone can read, write and execute. | Rarely right: any user on the system can change or replace the file. |
| 1777 | rwxrwxrwt | Everyone can do everything, but users cannot delete or rename each other's files. | Shared scratch directories such as /tmp. |
| 2775 | rwxrwsr-x | Like 775, and new files inherit the directory's group. | Shared project directories. |
How the octal number adds up
Read is worth 4, write 2 and execute 1. Add the ones a class has and you get its digit: rwx is 4 + 2 + 1 = 7, r-x is 4 + 1 = 5, rw- is 4 + 2 = 6 and r-- is 4. Three digits, owner, group and others, make the mode, so rwxr-xr-x is 755. This is the table in the GNU coreutils manual, and POSIX defines the same values.
An optional fourth digit goes in front for the special bits: 4 for setuid, 2 for setgid and 1 for the sticky bit. 4755 is 755 with setuid, 2775 is 775 with setgid and 1777 is 777 with the sticky bit. A mode with fewer digits gets leading zeros, so 0755 and 755 are the same, and so are 55 and 0055.
ls -l shows the special bits in the execute slots. s in the owner slot means setuid and execute, S means setuid without execute. The group slot uses s and S for setgid the same way, and the others slot shows t or T for the sticky bit. In a directory, read lets you list the names, write lets you create and delete files, and execute lets you open it and reach the files inside.
Symbolic modes: u+x, g-w, o=r
A symbolic mode names who to change (u for the owner, g for the group, o for others, a for all three), an operator and the permissions. + adds them, - removes them and = sets exactly those, so chmod g-w file takes write away from the group and leaves everything else alone. Several changes go in one argument with commas: chmod u=rwx,g=rx,o= file is 750.
Capital X adds execute only to directories and to files that someone can already execute, so chmod -R a+X folder makes every folder inside openable without making plain files executable. s sets setuid with u and setgid with g, and t sets the sticky bit.
Leave out the who letter, as in chmod +x script.sh, and chmod acts on all three classes but skips any bit your umask removes. With the common umask of 022, +x and a+x give the same result. The calculator applies a change without a who letter to all three classes.
One more rule from GNU chmod: on a directory, a numeric mode like 755 does not clear a setuid or setgid bit the directory already has. Use chmod 00755, or a symbolic mode such as g-s, to remove them.
Questions
What does chmod 755 mean?
The owner can read, write and execute (7 = 4 + 2 + 1), and the group and everyone else can read and execute (5 = 4 + 1). ls -l shows it as rwxr-xr-x. It is the usual mode for directories, scripts and programs that others need to run or open but not change.
What is the difference between chmod 644 and 755?
Execute. 644 (rw-r--r--) lets everyone read but nobody execute, which suits ordinary files. 755 (rwxr-xr-x) adds execute for all, which a script needs to run and a directory needs before anyone can open it.
Is chmod 777 safe?
Usually not. 777 lets every user and every process on the machine change, replace or delete the file's contents, so a bug or a compromised service can rewrite it. If several people need to write, give them a shared group and use 775 or 664. A shared scratch directory should be 1777, which adds the sticky bit so people cannot delete each other's files.
What permissions should an SSH key have?
600 or 400 for the private key, so only you can read it, and 700 for the ~/.ssh directory. ssh ignores a private key that other users can read. The public key (.pub) can be 644.
How do I make a script executable?
Run chmod +x script.sh, or chmod 755 script.sh to set the whole mode at once. +x adds execute without touching read and write, for everyone your umask allows (with the usual 022, the owner, the group and others). chmod u+x script.sh adds it for you alone.
What do s, S, t and T mean in ls -l?
They sit in an execute slot and show a special bit. Lowercase s in the owner or group slot is setuid or setgid with execute; uppercase S is the bit without execute. t in the others slot is the sticky bit with execute for others, T without. rwsr-xr-x is 4755 and rwxrwxrwt is 1777.
Is anything I enter sent or saved?
No. The calculator runs in JavaScript inside this tab. It only remembers the directory and -R options, in this browser. Page views are counted with Cloudflare Web Analytics, which does not see what you type.