A chmod calculator that works both ways
This chmod calculator turns Unix and Linux file permissions into every notation you are likely to need. Tick the boxes, type 755, or paste -rw-r----- straight from ls -l, and you get the "Octal notation", the "Symbolic notation (ls -l)", the "Octal command" and the "Symbolic command", each with a "Copy" button. Below, a plain-English summary says exactly who can do what. Nothing leaves your browser.
How to use it
- Type into "Permissions to convert": an octal number (644, 4755), a 9 or 10 character symbolic string, or chmod clauses such as
u=rwx,g=rx,o=org+w. - Or tick the "Tick the permissions" grid: Owner, Group and Others against Read, Write and Execute. The "Digit" column shows each row's value.
- Add a special bit if needed: setuid, setgid or sticky bit.
- Under "Applied to", pick "a file" or "a directory", because x means something different for each. Put your own name in "File name in the command".
- The "Presets" load 644, 755, 600, 700, 775, 664, 400, 1777 or 777 in one click.
Reading Linux permissions
Each permission has a value: read r = 4, write w = 2, execute x = 1. Add them up for each class. So 755 gives the owner 7 (4 + 2 + 1, rwx) and gives the group and others 5 (4 + 1, r-x): rwxr-xr-x. The symbolic version of the same command is chmod u=rwx,g=rx,o=rx file.
| Input | Result | Typical use |
|---|---|---|
| 644 | rw-r--r-- | HTML pages, images, readable config files |
| -rw-r----- | 640 | a file only the web server's group may read |
| 600 | rw------- | a private SSH key in ~/.ssh |
| 4755 | rwsr-xr-x | a setuid program such as passwd |
| 1777 | rwxrwxrwt | a shared directory such as /tmp |
| 2644 | rw-r-Sr-- | setgid without execute: capital S |
On a directory, r lets you list the names inside, w lets you create or delete files in it, and x lets you traverse it. Without x you cannot cd into it, even with r. A lowercase s means setuid or setgid with execute; a capital S means the same bit without execute. The sticky bit works the same way with t and T.
umask and default permissions
The "Default permissions with umask" block uses 666 & ~umask for files and 777 & ~umask for directories. With the common umask 022, a new file gets 644 and a new directory gets 755. A umask of 027 gives 640 and 750; 077 gives 600 and 700. "Load into the grid" sends the result back to the calculator.
Security: steer clear of 777
777 lets every account on the machine change, replace or run the file. On shared hosting or a VPS, that is how one compromised script can tamper with your whole site. The tool shows a warning as soon as others have write access. The usual rule for a website is 644 for files, 755 for directories and 600 for anything holding a password.
Frequently asked questions
What is the difference between chmod 755 and chmod 644?
755 adds execute permission for everyone, which directories and scripts need. 644 is enough for a file that only has to be read.
Why is there sometimes a fourth digit, as in 4755?
The leading digit holds the special bits: 4 for setuid, 2 for setgid, 1 for the sticky bit. 0755 and 755 are the same.
Can I paste a line from ls -l?
Yes. Paste the first 10 characters, for example drwxr-x---. The d switches the tool to "a directory" and the result is 750. A trailing dot or plus sign is accepted too.
Why does chmod 755 not clear setgid on a directory?
On Linux, chmod keeps the setuid and setgid bits of a directory when you give only three digits. To clear them, run chmod g-s dir or chmod 00755 dir.