Hello, everyone.
Now that you have learned how to assign permissions to file and directories using letters, but now
do you know you could also assign permissions using numerical values?
Yes.
So every time you have a file, you could assign permission to that file or directory using numerical
digits.
And how does it work so you know change mod you geo is for user group and other plus are two a file
will actually assign a read permission to everyone if you want to use in a numerical way you could do
change mod for for for and the file which will assign exactly the same permission as in the first command,
and the end result will be read, read and read permission only to everyone for a file.
Now how does that four, four, four changes and assign the permission?
Let's look at it by looking at the structure of a file.
So as you all know, owners assign permission on every file and directory.
And we have users and they have three types of permissions read, write executable group has three type
of permissions and everyone else or others or all have those type of permissions as well.
So we all know that.
Then let's go more specifically that the first three bits that we have already covered are for users,
the owner of the file, the secondary bits are for the group and the last three bits are for the others.
Now moving on the table below that I'm going to show you is actually assigns numbers or permissions
to the permission types.
So let's look at that table.
This is the table is something that you need to remember.
Now, if you have zero assigned, that means no permission.
One is for executable, two is for write, three is for execute plus write for is to read.
Five is to read and execute.
Six is to read and write and seven is to read or write and execute.
Now how does these all four seven numbers all all eight numbers work if I if I do change mod 764 to
a file, then it means the first digit will always be for the user itself.
So seven meanings.
If you look at the table, it means this is going to assign, read, write and executable permission
to the owner of the file.
The second letter, which is in this case is six.
It means that a read and write only and that will be assigned to the group.
And the last one is four, that is for others.
And the four means only read.
So only read will be assigned to the file.
So again, first digit is for user, second digit is for group and third digit is for others.
So let's try in our Linux machine, in our lab machine and see how it works.
So I'm going to create a file, let's say.
Sam, I'm going to touch and create a file.
Sam, I will do a list minus L here and the file is there.
By the way you I am logged in as myself and I am in my home directory.
So let's clear the screen by typing clear and do a les minus LTR again.
And you will see the SAM file is all all all the way at the bottom.
Now, by default I have given the permission as read, write, read, write and just read.
If you want to change this permission to seven, six, four meaning me as myself will have read, write
and executable and group will have only read right, and everyone else will just have read.
Then all I have to do is change mod seven six for Sam.
Now when you do ls minus ltr.
You will see right at the bottom.
I have now read write executable.
Read.
Write for the group and just read for everyone else.
Now, if I wanted to remove those permissions, let's clear the screen and just do a list minus.
L are only on same file.
So it's just only that file shows up on the list.
If I want to remove every permission of everyone else, I will do change mod 000 sam do list minus letter
by hitting up arrow key which will bring the last run command and you hit enter.
You'll see all the permissions are gone.
Now, if I wanted to, let's say if I wanted to assign, read and write permission only to myself.
Then how are you going to do it?
Then all you have to do is change mod.
Myself would be the first letter.
Remember the first.
Sorry, the first digit.
So I just want to read and write only.
So that would go for number six because if you look at the table, number six only gives, read and
write, then the rest I don't want to assign anything else.
So you cannot leave anything empty like that.
So you have to leave zero zero so no permission at all type it.
Sam if you do ls minus LTR on Sam you will see I only have read and write, so let's try one more time.
What if I want to keep the permission read and write and y to assign read permission to the existing
permission for others?
Meaning right here.
The last three bits I want are here.
So for that I would do first of all change mod and of course I wanted to keep the permission and that
permission is six for group.
I don't want to assign anything and for others I want only read.
And if you look at the table, the read number associated with read is four.
So if I do hit four and type Sam and now if I do ls minus l tr on Sam, you will see, read and write
and read is only given to others in this case.
Let's look at one more and last one example.
What if I want to assign executable permission to everyone in the in the system so you the chain mod
now what's executable.
The executable permission.
If you look at it, it's number one from the table.
So that means one, one and one because I want to assign executable to myself, to groups and to others.
So one, one, one and sample and let's do ls minus l tr and you will see it's only given x x x.
So now you can only executable if you wanted to have executable and read, then you will have given
number five and one one.
One which will give you.
Yourself executable and read and the rest only executable anyway.
That's how you use this table or that's how you use the numerical letters or sorry numerical digits
to assign permissions.
Also, if you do not remember this this chart or if it's not handy with you, you can also go online.
There are many calculators online that you could use.
All you have to do is type online, change mod calculator and it will come up.
A lot of websites have those free calculators for you.
All you have to do is pick click on the ownership or group or public meaning others, whatever that
you want to do, check those marks and at the bottom you'll see links permission.
It will give you the exact number that you need to type it in for change.
Mod It's very easy anyway.
You could do either way.
You could use.
You could do using the letters or you could do using the digits.
I just wanted to cover both methods so you understand how the permission works using both methods.