Instead of letters, chmod also takes three digits: one for the user (owner), one for the group and one for others. Each digit is a sum:
| Permission | Value |
|---|---|
| read (r) | 4 |
| write (w) | 2 |
| execute (x) | 1 |
So 7 = 4 + 2 + 1 = rwx, 6 = 4 + 2 = rw-, 5 = 4 + 1 = r-x, 4 = r-- and 0 = ---.
The ones you'll see most
| Mode | Letters | Typical use |
|---|---|---|
| 644 | rw-r--r-- | ordinary files: you edit, everyone reads |
| 600 | rw------- | private files: only you read or write |
| 755 | rwxr-xr-x | programs, scripts and directories: you change, everyone runs or enters |
| 700 | rwx------ | private scripts or directories |
chmod 600 diary.txtls -l diary.txtThe digits set all nine permissions at once, while letters like u+x change just one. Both are fine; numbers are quicker when you know the result you want.
You'll sometimes see chmod 777 suggested to "fix" a permission error. It lets everyone change and run the file. It's almost never the right answer.