- There is three types of permisions in files and folders in unix 1.1. Read (r) 1.2. Write (w) 1.3. Execute (x)
- And, there is a clasificacion of users called UGO (explained bellow): 2.1. U ~> User (usually, you) 2.2. G ~> Group (eg sudo group) 2.3 O ~> Others
When you run $ ls -l your output will be something like this:
-rwxrwxrwx@ 1 user staff 708301983 Aug 11 13:51 all.zip
-rw-r--r-- 1 user staff 0 Aug 22 22:10 chmodCheatSheet.md
-r--------@ 1 user admin 1692 Jul 6 10:13 deploykey.pem
drwxr-xr-x 3 user staff 102 Aug 20 19:14 deploynode
| U | G | O |
|---|---|---|
| r w x | r w x | r w x |
| 1 1 1 | 1 1 1 | 1 1 1 |
So, user, group and others can read, write and excute the file or folder
| U | G | O |
|---|---|---|
| r w - | r -- | r - x |
| 1 1 0 | 1 0 0 | 1 0 1 |
So, user can read and write, group and other only can read.
| U | G | O |
|---|---|---|
| r - x | r w - | - - - |
| 1 0 1 | 1 1 0 | 0 0 0 |
| - w x | r - x | - - x |
| 0 1 1 | 1 0 1 | 0 0 1 |
| Bin | Decimal | Representation |
|---|---|---|
| 000 | 0 | - - - |
| 001 | 1 | - - x |
| 010 | 2 | - w - |
| 011 | 3 | - w x |
| 100 | 4 | r - - |
| 101 | 5 | r - x |
| 110 | 6 | r w - |
| 111 | 7 | r w x |
- So, if I run
$ chmod 777 file<=>rwx rwx rwxeverybody can do anything with this file or folder! - Or I run
$ chmod 744<=>rwx r-- r--only user can read, write and execute, group and others only read. - Or run
$ chmod 200<=>-w- --- ---only you can write this file or folder
Thanks for reading, I hope it works! Follow me on Twita and GitHub
Refs: