chmod calculator: permissions to octal and back
Tick the permissions you want and get the chmod command, the octal number and the rwx string. Or type an octal number or an rwx string and see which boxes it means.
How the numbers work
Each permission is worth a number: read is 4, write is 2 and execute is 1. Add them up for each of owner, group and others. rwx is 4+2+1 = 7, r-x is 4+1 = 5, r-- is 4. So rwxr-xr-x is 755.
Modes you will use most
- 644 for ordinary files, 755 for scripts and directories.
- 600 for private files. SSH refuses a private key that others can read, so use chmod 600 on it.
- 700 for directories only you should enter, such as ~/.ssh.
- Avoid 777. It lets any account on the machine change the file.
The special bits
setuid and setgid make a program run with the rights of its owner or group, and the sticky bit on a shared directory, like /tmp, stops users deleting each other’s files. They add a fourth leading digit, for example 4755 or 1777.