Chmod calculator
Work out Linux file permissions in both directions. Tick read, write and execute to get the chmod number, the rwx letters and a command to copy, or type 755 or paste an ls -l line to see what it allows, in binary as well as octal.
| Who | Read 4 | Write 2 | Execute 1 | Digit |
|---|---|---|---|---|
| Owner u | ||||
| Group g | ||||
| Everyone else o |
Folders and files separately
Umask: default permissions for new files
Run umask in a terminal to see yours. New files start from 666 and folders from 777, and the umask removes bits from those. Press a result to load it above. The umask also limits changes typed without who, such as +x.
Runs in your browser. Nothing you type is uploaded.
How to use the chmod calculator
- Tick read, write and execute for the owner, the group and everyone else. The number and the letters update as you click.
- Or work backwards: type a number such as
755, letters such asrwxr-xr-x, or paste the start of a line fromls -l, for exampledrwxr-xr-x. - Set "Applies to" to a file or a folder, type the name, and copy the command. Tick Recursive to change a folder and everything inside it.
Below the commands, the calculator spells out what each group of users can do and warns about settings that cause trouble, such as a folder anyone can write to. "Apply a change" runs a letter change like g+w or o-rwx on the current permissions, the same way chmod would.
How chmod numbers work
Every file has three sets of permissions: one for its owner, one for its group, and one for everyone else. Each set has three switches, read (r), write (w) and execute (x), and each switch is one bit. Read is worth 4, write 2 and execute 1, so adding the ones you want gives a digit from 0 to 7.
| Digit | Binary | Letters | Means |
|---|---|---|---|
| 0 | 000 | --- | nothing |
| 1 | 001 | --x | execute |
| 2 | 010 | -w- | write |
| 3 | 011 | -wx | write and execute |
| 4 | 100 | r-- | read |
| 5 | 101 | r-x | read and execute |
| 6 | 110 | rw- | read and write |
| 7 | 111 | rwx | read, write and execute |
A chmod number is three of those digits in a row, one each for owner, group and everyone else. Take 755: 7 is 111 (read, write, execute), and each 5 is 101 (read and execute). Written as nine bits, 755 is 111 101 101, which ls -l shows as rwxr-xr-x.
That is why the digits stop at 7. A chmod number is written in octal, base 8, where each digit stands for exactly three bits, so you can read the permissions straight off the octal to binary conversion. 755 in octal is 493 in decimal, which you can check with the octal to decimal converter, and it is the number you would see if a program printed the mode without the octal prefix.
Common chmod values
| Number | Letters | Who can do what | Typical use |
|---|---|---|---|
777 | rwxrwxrwx | Everyone can read, change and run it | Almost never. See the 777 section below |
775 | rwxrwxr-x | Owner and group can do everything, others read and run | Folders a team shares through one group |
770 | rwxrwx--- | Owner and group can do everything, others nothing | Private team folders |
755 | rwxr-xr-x | Owner can do everything, others read and run | Folders, scripts and programs |
750 | rwxr-x--- | Owner everything, group read and run, others nothing | Web folders on hosts that run PHP as your user |
744 | rwxr--r-- | Owner everything, others read only | Scripts only the owner runs directly (others can still read them) |
700 | rwx------ | Only the owner, with full access | Private folders such as ~/.ssh |
666 | rw-rw-rw- | Everyone can read and change it | Rarely a good idea for a real file |
664 | rw-rw-r-- | Owner and group read and write, others read | Files a team edits together |
660 | rw-rw---- | Owner and group read and write, others nothing | Shared files that should stay private |
644 | rw-r--r-- | Owner reads and writes, others read | Most files, web pages, config files |
640 | rw-r----- | Owner reads and writes, group reads, others nothing | Config files with passwords on shared servers |
600 | rw------- | Only the owner can read and write | SSH private keys, files with secrets |
444 | r--r--r-- | Everyone can read, nobody can write | Files that should not change |
400 | r-------- | Only the owner can read | Locked-down keys and wp-config.php |
chmod 755
chmod 755 gives the owner read, write and execute, and gives the group and everyone else read and execute (rwxr-xr-x). It is the usual setting for folders, because execute on a folder is what lets people open it, and for scripts and programs that everyone on the system may run but only the owner may edit.
chmod 644
chmod 644 lets the owner read and write, and everyone else only read (rw-r--r--). Most ordinary files use it, including web pages and images on a server. On many Linux systems a new file starts as 644, because files begin at 666 and the default umask of 022 removes write for the group and everyone else.
chmod 600
chmod 600 lets only the owner read and write (rw-------). Use it for files that hold secrets. The ssh manual says a private key must not be accessible by others and that ssh ignores a key that is, which is why chmod 600 ~/.ssh/id_ed25519 is a common fix for the "UNPROTECTED PRIVATE KEY FILE" warning.
chmod 700
chmod 700 gives the owner full access and nobody else anything (rwx------). On a folder, such as ~/.ssh, it keeps other users from even listing what is inside. On a script, only the owner can read or run it.
chmod 775
chmod 775 is 755 with write added for the group (rwxrwxr-x). It suits a folder that several people in one group work in. Add setgid, chmod 2775, and new files inside take the folder's group automatically, so the rest of the team can still edit them.
chmod 777
chmod 777 (rwxrwxrwx) lets every user and every program on the machine read, change and run the file, or add and delete files in the folder. It often makes an error go away, which is why it gets suggested, but it fixes the wrong thing. The real problem is usually that the file belongs to the wrong user. Check with ls -l, fix the owner with chown, and use 755 or 775 instead. On shared hosting, the WordPress file permissions guide recommends 755 or 750 for folders, 644 or 640 for files, and 440 or 400 for wp-config.php.
Reading permissions in ls -l
Run ls -l and each line starts with ten characters, for example drwxr-xr-x or -rw-r--r--. The first character is the type: - for a file, d for a folder (directory) and l for a symbolic link. The other nine are the owner, group and everyone else, three letters each, with a dash where a permission is off.
Paste that part, or the whole line, into the letters box above to turn it into a number. A dot or plus at the end, such as drwxr-xr-x., only means the file has an SELinux label or an access control list, and macOS adds @ for extended attributes. The calculator ignores those. To print the number directly, use stat -c '%a %A' file on Linux or stat -f '%Lp %Sp' file on macOS.
Changing permissions with letters
Letters change only what you name, which makes them safer than a number when you want to adjust one bit. Each change is who, then an operator, then the permissions:
- Who:
uowner,ggroup,oeveryone else,aall three. - Operator:
+adds,-removes,=sets exactly and clears the rest. - Permissions:
r,w,x, plusX,sandt, which are covered below.
chmod u+x deploy.sh # owner can run it
chmod go-w notes.txt # group and others can no longer write
chmod o-rwx private/ # others lose all access
chmod u=rwx,g=rx,o= app/ # same as chmod 750
chmod a+r report.pdf # everyone can read
Leave out who, as in chmod +x script.sh, and the change applies to everyone except for bits your umask blocks. With the usual umask of 022, chmod +x adds execute for all three, but chmod +w adds write for the owner only.
Making a script runnable is the most common use: chmod +x script.sh, then run it with ./script.sh. If it then fails with "bad interpreter" and a ^M, the file was saved with Windows line endings, and the guide to LF and CRLF line endings shows how to convert it.
Setuid, setgid and the sticky bit
A fourth digit in front of the usual three holds three special bits, worth 4, 2 and 1 in the same way as read, write and execute.
| Bit | Digit | On a file | On a folder | Shows in ls -l as |
|---|---|---|---|---|
| Setuid | 4 | The program runs with the owner's rights. /usr/bin/passwd uses it to update the password file. | Ignored on Linux | s in the owner's execute spot |
| Setgid | 2 | The program runs with the file's group | New files inside take the folder's group | s in the group's execute spot |
| Sticky | 1 | Ignored on Linux | Only a file's owner can delete or rename it | t in the last spot |
So chmod 4755 shows as rwsr-xr-x, and chmod 1777, the setting on /tmp, shows as rwxrwxrwt. A capital S or T means the special bit is on but execute is off underneath it. A capital S is usually a mistake, while a capital T on a folder can be harmless. Linux ignores setuid on shell scripts, so it only matters for compiled programs.
On a folder, GNU chmod keeps setuid and setgid when you set a plain three-digit number, so chmod 755 on a setgid folder leaves it at 2755. To clear them, use letters (chmod g-s folder) or five digits (chmod 00755 folder).
Umask and the permissions new files get
New files are not created with 777. Programs usually ask for 666 for a file and 777 for a folder, and the umask then removes bits from that. The umask is written like a chmod number, but each 1 bit in it switches a permission off.
| Umask | New files | New folders | Where you see it |
|---|---|---|---|
022 | 644 rw-r--r-- | 755 rwxr-xr-x | System default on most Linux systems and macOS; many distros give regular users 002 |
002 | 664 rw-rw-r-- | 775 rwxrwxr-x | Regular users on Fedora and other systems that give each user a group of their own |
027 | 640 rw-r----- | 750 rwxr-x--- | Servers that keep files from other users |
077 | 600 rw------- | 700 rwx------ | Strict setups, only the owner sees anything |
Type umask in a terminal to see yours, and open "Umask: default permissions for new files" in the calculator to try another value. Changing it with umask 027 lasts until the shell closes. To keep it, add the line to ~/.bashrc or ~/.profile.
Changing a folder and everything in it
chmod -R works through a folder and everything inside it. The catch is that chmod -R 755 site/ also makes every file inside executable, because files and folders get the same number. Two ways to avoid that:
# Capital X: execute for folders, and for files that already had it
chmod -R u=rwX,go=rX site/
# Or set folders and files separately
find site/ -type d -exec chmod 755 {} +
find site/ -type f -exec chmod 644 {} +
Capital X in the first command gives execute only to folders and to files that already have execute for someone, according to the GNU description of X. Tick Recursive in the calculator with a folder selected, and it writes both versions for the permissions you picked.
When chmod does not seem to work
- You run
chmod 644 notes.txtand get "Operation not permitted". Only the file's owner or root can change permissions, so check the owner inls -land usesudoor ask the owner. The same error comes from drives formatted as FAT32, exFAT or NTFS, which usually do not store Linux permissions. Their permissions come from how the drive is mounted. - The file is 644 but you still get "Permission denied" opening it. Every folder on the way to it needs execute for you, and one of them is probably missing it.
namei -l /path/to/notes.txtlists the permissions of each folder in the path so you can spot the one that is closed. - You set
chmod +xon a script and it still will not run. If the message mentions^M, the file has Windows line endings. If the file sits on a USB drive or in/tmpon a hardened server, the drive may be mounted withnoexec, which blocks running anything from it.bash script.shstill works there, because bash only needs to read the file. - After
chmod -R 755, Git says every file changed. Git records the execute bit, and the command added it to every file. Put the files back withfind . -type f -exec chmod 644 {} +and set execute only on the scripts that need it.
Setting permissions from code
Most languages take the same number, but you have to write it in octal. In Python that means the 0o prefix, covered in the guide to Python number prefixes and conversions:
import os, stat
os.chmod("deploy.sh", 0o755)
print(oct(os.stat("deploy.sh").st_mode & 0o777)) # 0o755
print(stat.filemode(os.stat("deploy.sh").st_mode)) # -rwxr-xr-x
Writing os.chmod(path, 755) without the prefix is a common bug. Decimal 755 is octal 1363, so the file ends up as -wxrw--wt with the sticky bit set. The & 0o777 in the second line is a bit mask that keeps only the nine permission bits, the same trick shown in the Python bitwise operators guide. In Node.js the call is fs.chmodSync('deploy.sh', 0o755).
Questions people ask
What does chmod stand for?
Change mode. The mode is the set of permission bits stored with every file, and chmod is the command that changes it.
What does chmod 755 mean?
The owner can read, write and run the file, and everyone else can read and run it but not change it. In letters it is rwxr-xr-x, and in binary 111 101 101.
What is the difference between chmod 755 and 777?
With 777 every user can also change the file, or add and delete files in the folder. 755 keeps writing to the owner only. Use 755 unless several users really must write to the same place, and even then 775 with a shared group is safer.
What is the difference between 644 and 755?
Execute. 644 (rw-r--r--) is for files that are only read, such as text, images and web pages. 755 (rwxr-xr-x) adds execute, which a script or program needs to run and a folder needs to be opened.
What does chmod 444 mean?
Everyone can read the file and nobody can write to it, including the owner (r--r--r--). The owner can still change the permissions back, and root ignores them.
How do I calculate chmod permissions by hand?
Add 4 for read, 2 for write and 1 for execute, once for the owner, once for the group and once for everyone else, and write the three totals side by side. Read and write for the owner (4 + 2 = 6) and read only for the others (4) gives 644.
What does drwxr-xr-x mean?
It is a folder (the d) with permissions 755: the owner can list, change and open it, and everyone else can list and open it.
Does chmod work on macOS?
Yes. macOS uses the same numbers, letters and special bits. The differences are in other commands: macOS uses stat -f '%Lp' instead of stat -c '%a', and its ls -l adds @ when a file has extended attributes.
Does Git keep file permissions?
Only the execute bit. Git stores each file as either 644 or 755, so other permission changes are not committed. If a chmod makes Git list files as changed, that is the execute bit, and git config core.fileMode false tells Git to ignore it.

