The maximum file permissions (ie Read, Write, and Execute) that can be assigned to a directory or file on a Unix-based operating system (including Linux).
777 = "-rwxrwxrwx" = rwx for all
0 --- no permission
1 --x execute
2 -w- write
3 -wx write and execute
4 r-- read
5 r-x read and execute
6 rw- read and write
7 rwx read, write and execute
The first character in the mode string -rwxrwxrwx
indicates file type and is not related to permissions, a couple of examples:
-rwxrwxrwx // normal file
drwxrwxrwx // directory
lrwxrwxrwx // symbolic link
prwxrwxrwx // named pipe
srwxrwxrwx // socket
From maketecheasier:
Every file and folder contains 8-bit data that controls the permissions. At its basic binary form, it will be “000”, which means no permission of any form is granted. When you set a “Read” permission, it will add 4-bit to the data, making it “100” (in binary format) or a “4” in the usual decimal format. Setting a “Write” permission will add 2-bit to the data, making it “010” and “2” in decimal form. Lastly, setting an “Execute” permission adds 1-bit to the data, which will result in “001”, or “1” in decimal form. In short:
- Read is equivalent to ‘4’.
- Write is equivalent to ‘2’.
- Execute is equivalent to ‘1’
When we want to set permissions, we just add up the number. For example, to set the permissions to read and write, we will use ‘6’ (4 + 2) for the permission. For read, write and execute, we will use ‘7’ (4 + 2 + 1) for the permission.