Every file on Linux, macOS and other Unix systems has a permission mode like 755 or rw-r--r--, and a chmod calculator works out those numbers and letters for you. Tick the permissions above, or type a mode like 755 or rwxr-xr-x, and you'll get the matching octal value, symbolic form, binary bits and a ready-to-run chmod command. Here's how Unix permissions work, what the common chmod values mean, and how the special bits fit in.
How Linux file permissions work
Every file and folder has an owner and a group, and three sets of permissions: one for the owner, one for members of the group, and one for others, meaning everyone else. Each set has three switches: read (r), write (w) and execute (x). Run ls -l and you'll see them as a string like -rwxr-xr-x. The first character is the file type (- for a file, d for a directory), and the next nine are the owner, group and others permissions, three letters each, with a dash where a permission is off.
How chmod numbers work
The chmod command can set all nine permissions with a three-digit number, one digit per class. Read is worth 4, write is worth 2 and execute is worth 1, and each digit is the sum of the permissions that are on. Read, write and execute together are 4 + 2 + 1 = 7. Read and execute are 4 + 1 = 5. Read and write are 4 + 2 = 6. So chmod 755 gives the owner everything (7) and gives the group and others read and execute (5), which is rwxr-xr-x.
Permissions in binary
The numbers aren't arbitrary. Each chmod digit is an octal digit, and every octal digit is exactly three bits: one for read, one for write and one for execute. 7 is 111, 5 is 101 and 4 is 100, so 755 is the nine bits 111 101 101, a 1 wherever a permission is on. That's why permissions are written in octal rather than decimal. The In binary panel shows the bits for any mode, and the octal to binary converter explains the grouping.
Common chmod values
| Mode | Symbolic | Typical use |
|---|---|---|
| 755 | rwxr-xr-x | Scripts, programs and folders |
| 644 | rw-r--r-- | Ordinary files such as web pages and documents |
| 600 | rw------- | Private files, like SSH keys |
| 700 | rwx------ | Private folders and scripts, like ~/.ssh |
| 775 | rwxrwxr-x | Shared folders a group can write to |
| 664 | rw-rw-r-- | Shared files a group can edit |
| 444 | r--r--r-- | Read-only for everyone |
| 777 | rwxrwxrwx | Everyone can do anything (avoid) |
SSH is strict about this: it refuses to use a private key that other users can read, so keys need 600 and the ~/.ssh folder 700. chmod 777 is almost never the right fix for a permission error, because it lets any user or compromised process on the machine change the file.
Permissions on directories
The same three letters mean slightly different things for a folder. Read lets you list the names inside it, write lets you create, rename and delete files in it, and execute lets you enter it with cd and reach the files inside. A folder needs execute to be usable at all, which is why folders are usually 755 or 700 while plain files are 644 or 600.
Setuid, setgid and the sticky bit
A fourth, leading digit sets three special bits, worth 4, 2 and 1 just like the others:
| Mode | Bit | Symbolic | Used for |
|---|---|---|---|
| 4755 | Setuid (4) | rwsr-xr-x | Programs that need their owner's rights, like passwd |
| 2775 | Setgid (2) | rwxrwsr-x | Shared folders where new files keep the folder's group |
| 1777 | Sticky (1) | rwxrwxrwt | Shared folders like /tmp, where users can't delete each other's files |
In the symbolic form, the special bits replace the execute letter: s for setuid and setgid, t for sticky. A capital S or T means the special bit is set but execute isn't, which is usually a mistake.
Symbolic chmod and umask
chmod also accepts letters, which change permissions without retyping the rest: chmod u+x script.sh adds execute for the owner, chmod go-w file removes write for the group and others, and chmod u=rwx,g=rx,o=rx file sets the same thing as 755. The calculator shows that form under Commands. New files get their starting permissions from the umask, which removes bits from a default of 666 for files and 777 for folders. The common umask 022 removes write for group and others, so new files are 644 and new folders 755.
Working safely with chmod
- Paste the permissions straight from
ls -l, including the leading-ord. - Add
-Rto apply a mode to a folder and everything in it, but be careful: files and folders usually need different modes. - To read the current mode as a number, run
stat -c %a fileon Linux.
When in doubt, start from 644 for files and 755 for folders and scripts, then tighten from there. It's rarely right to reach for 777.