I am always having problems when I need to assign a permissions to a folder (directory) or a file and always forgot which chmod numeric values I have to use. I collected all the chmod numeric values along with their permissions details in this table.
This table shows what numeric values mean:
| Octal digit | Text equivalent | Binary value | Meaning |
|---|---|---|---|
| 0 | --- | 000 | All types of access are denied |
| 1 | --x | 001 | Execute access is allowed only |
| 2 | -w- | 010 | Write access is allowed only |
| 3 | -wx | 011 | Write and execute access are allowed |
| 4 | r-- | 100 | Read access is allowed only |
| 5 | r-x | 101 | Read and execute access are allowed |
| 6 | rw- | 110 | Read and write access are allowed |
| 7 | rwx | 111 | Everything is allowed |
Here it can be noted that "1" stands for execute only, "2" stands for write only, "4" stands for read only.
To combine the permissions you can simply add 1, 2 and 4 to get a needed combination. For instance, to get read and write permissions, you add 4 (read) and 2 (write), thus getting 6 (read and write). To get read and execute permissions, you add 4 (read) and 1 (execute), thus getting 5 (read and execute).
