Linux file permissions are represented either in symbolic or in octal notation. In the last lecture, 1
we've talked about the symbolic notation, which means using the R, W and X letters for each set of 2
permissions assigned to each user category. 3
A hyphen is used if a specific permission is not set. 4
The most common form of seeing the symbolic notation is to run the ls -l command. 5
I'll run the commands as a non privileged user. 6
Another method of representing Linux permissions is an is an octal or base-8 notation. You can see 7
this notation as well, as the symbolic one by running the stat command. For example stat /etc 8
/passwd 9
And you see here the file's permissions, both in octal and symbolic notation; the number that represents 10
the permission in base 8 can be either a 3 or 4 digit number with digits from 0 to 7. 11
In fact, you can omit the first to 0 value 12
so a 4 digit number, with a leading 0, can be represented as a 3 digit number without that leading 13
0. 14
So 0755 = 755 or 0644 = 644 15
When a 3 digit number is used, the first digit represents the permissions of the file’s owner, 16
the second one the file’s group, and the last one the permissions of the others class. 17
In this no notation, the values r, w and x have their own fixed number value. 18
r (read) = 4, w (write) = 2, x (execute) = 1, 19
A hyphen, which means no permissions = 0. The permissions number of a specific user class 20
is represented by the sum of the values of the permissions for that category. 21
Let's take some examples. 22
Let's suppose that the category has r w x permissions; in octal notation, that means 4 (r is 4) 23
+ 2 (w is 2) + 1 (because x is 1). 24
So in fact, it's 7. 25
Another one: rw* 26
That category doesn't have the execute permission, and that means 4 + 2 + 0=6. 27
Or if you have R--. 28
It means 4 (for read) + 0 for both write and execute. 29
So =4. 30
Now, let's try some examples with all permissions. 31
What is octal notation? And it means 4 + 2 + 0 for the user, for the owner, 32
4 + 2 + 0 for the group 33
And 4 + 2 + 0 for the others. 34
So the file's permissions in the octal notation are 6 6 4 35
Let's take another on! 36
This is not so common, but it is correct. 37
File can have any possible permissions. 38
And it means: 39
4 + 2 + 1 = 7 for the owner, 4+0+0=4 for the 40
group and the 0+2+1=3 for the others. 41
And the last one! 42
And we have 4+2+1 for the user, 43
4+0+1 for the group 5; 44
And 4+0+0 for the others. 45
Until you understand how to transfer the permission represented in the simple notation into the numeric 46
one, you can always check both systems using stat. 47
The actual notation and the symbolic one! 48
This is the octal rotation and this is the symbolic one. 49
This d here is for directory, for the file's type. 50
It doesn't belong to the file's permissions. 51
If you need more examples, you can take a look at this wiki page and see all possible combinations.