What is a chmod calculator?
On Linux, macOS and other Unix systems every file and directory has a mode: a small set of bits that says who may read it, who may write it and who may run it. The chmod command changes that mode, and it accepts it in two notations that people constantly translate in their heads. Octal is three digits such as 755. Symbolic is nine letters such as rwxr-xr-x, the same thing you see in the first column of ls -l. A chmod calculator converts between them and builds the command, so you do not have to add 4, 2 and 1 in your head at the worst possible moment.
The logic is small. Permissions come in three groups: the owner (u), the group (g) and everyone else (o). Each group has read (4), write (2) and execute (1), and the digit of a group is the sum of the bits it has. So 7 is read, write and execute, 5 is read and execute, 4 is read only, and 0 is nothing. A fourth, leading digit holds the special bits: setuid (4), setgid (2) and sticky (1), written as 4755 or 1777.
You use a calculator when a deploy fails with a permission denied, when SSH refuses a key because its permissions are too open, when you configure a web server folder or a shared directory, or when a tutorial says chmod 755 and you want to know what that actually grants. SSH key files are the classic case: generate a pair with the RSA key pair generator and protect the private one with chmod 600. The page also covers -R, chmod expressions like u+x and the umask. Everything runs in your browser. For octal and other number bases, see the base converter.
How to calculate chmod permissions
- Tick the boxes. The grid has a column for the owner, the group and the public (others) and a row each for read, write and execute. The octal number, the symbolic string and the
ls -lform of the mode (for example-rw-r--r--) update at once, in large type. The page opens with644, and the last mode you used is remembered. - For special bits, use the row below the grid: setuid belongs to the owner, setgid to the group and sticky to the public column. The octal then gets a fourth leading digit, such as
4755. - Copy what you need with the buttons for octal and symbolic. The command field below shows the full line, for example
chmod 755 path. Tick the recursive option to add-Rand apply it to everything inside a folder. - To go the other way, type a value in the octal field (
755or4755) or in the symbolic field (rwxr-xr-x, or the ten characters ofls -lsuch asdrwx------). The checkboxes follow as soon as the value is valid; if it is not, a message says what is wrong. - To apply a chmod expression such as
u+x,g-w,o=rto the current mode, type it in the expression field and press apply (or Enter). The result is previewed before you apply it. - In the umask section, type a mask or leave the field empty. The page shows the mode that new files and new directories get with that mask, and the mask that gives the mode on screen when used on a directory.
Examples
The usual modes
These are the combinations worth memorising:
| octal | symbolic | typical use |
|---|---|---|
644 | rw-r--r-- | regular files, such as web pages |
755 | rwxr-xr-x | programs and directories |
600 | rw------- | private files, such as an SSH private key |
700 | rwx------ | private directories, such as ~/.ssh |
Special bits
Setuid, setgid and sticky have their own characters in the symbolic form:
| octal | symbolic | meaning |
|---|---|---|
4755 | rwsr-xr-x | setuid: the program runs with the owner's rights |
2775 | rwxrwsr-x | setgid on a directory: new files inherit the group |
1777 | rwxrwxrwt | sticky: in a shared folder like /tmp, only the owner can delete a file |
4644 | rwSr--r-- | capital S: setuid set but execute not set |
Applying expressions
Starting from 644, u+x gives 744 (rwxr--r--). Starting from 664, g-w,o=r gives 644. Starting from 700, go=u copies the owner's permissions to the group and the others and gives 777. a+X on 644 changes nothing, because X sets execute only when some class already has it.
Common errors and how to fix them
- Use 3 digits (644) or 4 digits when you need setuid, setgid or sticky (4755): the octal has one or two digits, or more than four. Write
0644or644, not64. - Octal digits go from 0 to 7: you typed
8,9or a letter. For example888is not a mode. - Use 9 characters like rwxr-xr-x (or 10 with the ls -l type character): the symbolic string is too short or too long.
- Each triplet is r or -, w or -, then x or -: a letter is in the wrong place.
rwxr-xr-zfails at position 9. The letterssandSare valid in the owner and group triplets andtandTin the last one. - There is an empty part between commas: an expression like
u+x,ends with a comma. Remove it.
Frequently asked questions
What does chmod 755 mean?
The owner can read, write and execute; the group and everyone else can read and execute. It is the usual mode for programs, scripts and directories that others must be able to enter.
What is the difference between chmod 644 and 755?
Execute. 644 is rw-r--r--, fine for data files; 755 is rwxr-xr-x, which adds the execute bit for everyone. On a directory, execute means permission to enter it, which is why directories normally get 755.
Is chmod 777 safe?
No. It lets any user on the machine read, change and run the file, so it should be avoided on servers. If something works only with 777, the real fix is usually to change the owner or the group with chown.
How to change permissions in code
Bash
chmod 755 script.sh # octal
chmod u+x,g-w script.sh # symbolic
chmod -R u=rwX,go=rX site/ # folders get execute, plain files do not
ls -l script.sh # -rwxr-xr-x ...
stat -c '%a %A' script.sh # Linux: 755 -rwxr-xr-x
stat -f '%Lp %Sp' script.sh # macOSPython
import os
import stat
os.chmod("script.sh", 0o755)
mode = os.stat("script.sh").st_mode
print(oct(stat.S_IMODE(mode))) # 0o755
print(stat.filemode(mode)) # -rwxr-xr-xJavaScript
In Node, fs.chmod takes the octal mode; write it with the 0o prefix.
import { chmodSync, statSync } from 'node:fs';
chmodSync('script.sh', 0o755);
const mode = statSync('script.sh').mode & 0o777;
console.log(mode.toString(8)); // 755