How the numbers work
Each of the three groups – owner, group, others – gets a digit: read = 4, write = 2, execute = 1, added together. So 7 = rwx, 6 = rw-, 5 = r-x, 4 = r--.
| Number | Meaning | Typical use |
|---|---|---|
| 644 | rw-r--r-- | normal files, web pages |
| 755 | rwxr-xr-x | folders, scripts and programs |
| 600 | rw------- | private files: SSH keys, passwords, config with secrets |
| 700 | rwx------ | private folders, ~/.ssh |
| 777 | rwxrwxrwx | almost never a good idea – everybody can change everything |
For folders, "execute" means "may enter the folder". The optional fourth digit in front sets the special bits: setuid (4), setgid (2) and sticky (1) – for example 1777 on /tmp. More Linux commands are on the Linux cheat sheet.