Each set of three permissions can be written as one number. Add the numbers of the permissions that are on:
| Letter | Number |
|---|---|
r | 4 |
w | 2 |
x | 1 |
| Set | Sum | Number |
|---|---|---|
--- | 0 | 0 |
r-- | 4 | 4 |
r-x | 4 + 1 | 5 |
rw- | 4 + 2 | 6 |
rwx | 4 + 2 + 1 | 7 |
Three numbers, nine permissions
The owner, the group, all other accounts: three sets, three numbers.
6owner: rw- = 64group: r-- = 40others: --- = 0
text
learner@tidepool:~$ chmod 640 rota.txt
learner@tidepool:~$ ls -l rota.txt
-rw-r----- 1 learner staff 18 Oct 12 09:14 rota.txtstat -c %a writes the number:
text
learner@tidepool:~$ stat -c '%a %n' rota.txt
640 rota.txtCommon numbers
| Number | Permissions | Use for |
|---|---|---|
644 | rw-r--r-- | A normal file: the owner changes it, all can read it |
640 | rw-r----- | A settings file: the group can read it, others cannot |
600 | rw------- | A secret: only the owner |
755 | rwxr-xr-x | A program, or a directory that all can enter |
750 | rwxr-x--- | A program or a directory for the owner and the group only |
Numbers or letters?
A number sets all nine permissions at one time. Letters such as u+x change only what you name. Use a number when you know the full result that you want.