Using it
Type three octal digits, such as 755, or four for the special bits, such as 4755. The output is the permission string as ls -l shows it, and the rows say what the owner, the group and everyone else can do, with the chmod command to copy.
Swap the boxes to go the other way. Paste a string such as rwxr-xr-x, or the whole -rwxr-xr-x from ls -l: the file type letter at the front is ignored.
How the numbers work
Each digit covers one set of people: the file's owner, its group, and everyone else, in that order. Within a digit, read is 4, write is 2 and execute is 1, and you add up the ones you want. 7 is 4 + 2 + 1, all three; 5 is 4 + 1, read and execute; 6 is 4 + 2, read and write. So 755 lets the owner do everything and everyone else read and run it.
Each digit is really three bits, one per permission, which is why permissions are written in octal: one octal digit is exactly three bits.
Each digit
| Digit | Letters | Allows |
|---|---|---|
| 7 | rwx | read, write, execute |
| 6 | rw- | read, write |
| 5 | r-x | read, execute |
| 4 | r-- | read |
| 3 | -wx | write, execute |
| 2 | -w- | write |
| 1 | --x | execute |
| 0 | --- | nothing |
Common settings
| Number | Letters | Typical use |
|---|---|---|
| 755 | rwxr-xr-x | Programs, scripts and directories others may enter |
| 644 | rw-r--r-- | Ordinary files others may read |
| 700 | rwx------ | Private directories and scripts |
| 600 | rw------- | Private files, such as SSH keys |
| 775 | rwxrwxr-x | Shared directories a group writes to |
| 1777 | rwxrwxrwt | /tmp: anyone can write, only owners can delete |
Setuid, setgid and the sticky bit
A fourth digit in front sets three special bits. 4 is setuid: a program runs with its owner's rights instead of the user's, which is how passwd can update a file only root may write. 2 is setgid: a program runs with its group's rights, and on a directory, new files take the directory's group. 1 is the sticky bit: on a directory such as /tmp, people can only delete their own files.
In the letters, they replace the x of the owner, the group or others with s, s or t. A capital S or T means the special bit is set but the x underneath isn't, which is usually a mistake.
Questions
What does chmod 755 mean?
rwxr-xr-x: the owner can read, write and run it; the group and everyone else can read and run it.
What does chmod 644 mean?
rw-r--r--: the owner can read and write; everyone else can only read.
Is chmod 777 safe?
Rarely. It lets anyone on the system change the file. Use it only if you're sure, and never on a web server's files.
What does x mean on a directory?
Permission to enter it and reach the files inside. Read on a directory lets you list the names.
Sources
Added . What's new






