ACLClouds
ACLClouds

Chmod calculator

Work out chmod permissions in octal (755, 644) and rwx, with ready-to-copy commands. Owner, group and others grid. Free, runs in your browser.

Tick the permissions for owner, group and others: the calculator gives the octal value, the rwx form and the chmod command to run on your Linux server. Everything runs in your browser.

What does chmod 755 mean?

A chmod mode is three digits from 0 to 7: the first for the file owner, the second for its group, the third for every other account. Each digit is the sum of three rights: read 4, write 2, execute 1.

So 755 gives 7 (4+2+1, rwx) to the owner and 5 (4+1, r-x) to the group and others. ls -l shows the same thing in letters: rwxr-xr-x. An optional fourth digit in front holds the special bits: 4 for setuid, 2 for setgid, 1 for the sticky bit (1777 on /tmp).

Digit Letters Rights
0 --- No access
1 --x Execute
2 -w- Write
3 -wx Write and execute
4 r-- Read
5 r-x Read and execute
6 rw- Read and write
7 rwx Read, write and execute

Files vs directories: what x really means

On a file, r lets you read the content, w lets you change it and x lets you run it as a program or script.

On a directory, r lets you list the names inside, w lets you create, rename or delete entries (x is needed too), and x lets you enter it and reach files by name. Without x a directory stays closed even if its files are readable, which is why directories get 755 and files 644.

Deleting a file depends on the permissions of its directory, not of the file itself. The sticky bit (t) fixes that in shared directories: each user can only delete their own files.

Common chmod values on a server

Value Form Typical use
644 rw-r--r-- Website files, readable config files
755 rwxr-xr-x Directories, scripts and programs
600 rw------- SSH private keys, ~/.ssh/authorized_keys, .env files
700 rwx------ The ~/.ssh directory, private directories
400 r-------- Read-only private key (.pem file)
640 rw-r----- Config read by a service group
775 rwxrwxr-x Directory shared by members of a group
1777 rwxrwxrwt /tmp: everyone writes, each user deletes only their own files
777 rwxrwxrwx Avoid: anyone can modify

OpenSSH checks these modes: ssh ignores a private key that other accounts can access ("UNPROTECTED PRIVATE KEY FILE"), and sshd refuses key login when ~/.ssh or authorized_keys is writable by others (StrictModes, on by default).

chmod -R: change a whole directory without breaking the site

chmod -R 755 /var/www/site applies 755 to everything, files included, so every file becomes executable. chmod -R 644 is worse: directories lose x and can no longer be entered. Handle directories and files separately with find:

  • find /var/www/site -type d -exec chmod 755 {} + for directories
  • find /var/www/site -type f -exec chmod 644 {} + for files
  • or in one command: chmod -R u=rwX,go=rX /var/www/site (capital X: execute only for directories and files that are already executable)
  • chmod does not change ownership: if the web server must write, fix the owner with chown (for example chown -R www-data:www-data) instead of going to 777.

umask: permissions of new files

New files start from 666 and new directories from 777, minus the bits of the umask. With the usual server umask of 022 you get 644 and 755. Type umask to see yours; with 077, files are created as 600 and directories as 700.

GNU chmod keeps the setuid and setgid bits of a directory when given a three-digit mode such as 755: to clear them, write 00755 or use g-s.

Frequently asked questions

What does chmod 777 mean?

Read, write and execute for the owner, the group and every other account on the machine. It is rarely needed and risky: any service, including a hacked website, can change the file. Fix the owner with chown instead.

What is the difference between chmod 755 and 644?

755 adds the execute right (x) for everyone. Use it on directories and scripts; 644 suits ordinary files, readable by all but writable only by their owner.

What permissions for ~/.ssh and authorized_keys?

700 for the ~/.ssh directory, 600 for authorized_keys and private keys. If other accounts can write to them, sshd refuses key login (StrictModes).

How do I see the current permissions of a file?

ls -l file shows the rwx form and stat -c '%a %n' file shows the octal value. Paste the ls -l column into the calculator to convert it.

Why do I get "Permission denied" when running my script?

The file probably lacks the execute right: chmod +x script.sh or chmod 755 script.sh. Also check that the first line (#!/bin/bash) points to an interpreter that exists.

Does the calculator send my data anywhere?

No. Everything is computed in your browser; nothing is sent to ACLClouds.