Octal Permissions
In order to understand octal permissions we need to use the stat
command:
Output:
Here we can see the owner permission is 6, group permission is 4, and other permission is 0, but how do these numbers are calculated?
To better understand the octal permissions we need to understand the binary table:
Example: As we can see in the above example about the rwx permissions, if we look closely:
-rw-r-----
-rw
: shows 110r--
: shows 100---
: shows 000
Looking at the binary table:
000
0
001
1
010
2
011
3
100
4
101
5
110
6
111
7
Example: For another example lets see how we can use octal values to set permission for a file:
Suppose we want to give read, write and executing permissions to the user how will the octal values look like?
We gave 7 as we wanted the user to have read, write and executing permissions and group had 4 means group had only read permission and others had 0 as per the binary table.
Last updated