Chmod 755, 644 and 600: Linux File Permissions Explained
Short answer: chmod 755 gives the owner read, write and execute, and everyone else read and execute. 644 gives the owner read and write and everyone else read only. 600 gives the owner alone read and write. If you would rather tick boxes than do the arithmetic, the Chmod Calculator shows the octal value, the symbolic form and a ready-to-run command together.
How the numbers work
Unix and Linux store permissions as a number. There is one digit for each class of user, in this order: owner, group, other. Each digit is the sum of three values:
- read = 4
- write = 2
- execute = 1
So 7 is 4+2+1 (read, write, execute), 5 is 4+1 (read, execute), and 4 is read only. To see the bits behind a digit, convert it with the Number Base Converter: 7 is 111, 5 is 101 and 4 is 100.
The values you will use most
| Octal | Symbolic | Typical use |
|---|---|---|
| 644 | rw-r--r-- |
Normal files that only the owner may edit |
| 755 | rwxr-xr-x |
Programs, scripts and directories others may enter |
| 600 | rw------- |
Private files such as SSH keys |
| 777 | rwxrwxrwx |
Everyone can do everything. Avoid it on servers |
chmod 755 filename sets the exact mode. The symbolic form chmod u=rwx,g=rx,o=rx filename does the same thing.
What "execute" means on a directory
This is the part people get wrong. On a directory, read lets you list the names, write lets you add or remove entries, and execute lets you enter it and reach the files inside. Without execute, the files cannot be opened even if they are readable. That is why a directory is usually 755 or 700, not 644.
Three common mistakes
- Recursive chmod.
chmod -R 755 dirgives every file the execute bit as well. Set directories and files separately if you only want directories to be enterable. - Keys that are too open. OpenSSH refuses a private key that other users can read. Use
600for the key and700for the~/.sshdirectory. Keep such files out of version control too: see the .gitignore guide. - Scripts without execute. A script needs the execute bit before you can run it directly or schedule it. For the schedule, see the cron expression guide.
Special bits: setuid, setgid and sticky
A fourth, leading digit adds special bits: setuid (4), setgid (2) and sticky (1). They show up as s or t in the symbolic form.
4755isrwsr-xr-x. The setuid bit makes a program run with the permissions of its owner. Use it only when it is really needed.1777isrwxrwxrwt. The sticky bit on a shared directory such as/tmpmeans users can delete only their own files there.- setgid makes new files in a directory inherit its group, or makes a program run with its group's permissions.
How to calculate chmod 755 and other modes with the Chmod Calculator
- Open the Chmod Calculator.
- Tick the read, write and execute boxes for owner, group and other, or type an octal value such as
755. - Copy the octal, symbolic or command form.
- Replace
filenamewith your real path before you run it.
Limits to know
- It builds the command text. It does not change any file.
- Check the path before running
chmod, especially with-R. - Everything runs in your browser.
Frequently asked questions
What does chmod 755 mean? Owner: read, write, execute. Group and others: read and execute.
What is the difference between 644 and 600? 644 lets everyone read the file. 600 lets only the owner touch it.
Why does SSH say my private key is too open?
Other users can read it. Set the key to 600 and ~/.ssh to 700.
Is chmod 777 ever a good idea? Rarely. Any user on the machine can change the file.
Is chmod -R safe? It applies one mode to everything below, which is seldom what you want.