Hello everyone and welcome to this
video.
So in this video we are going to learn about Linux permissions
Linux permissions are very very important
and every one of you should know how these
permissions work.
And how to implement these types
of permissions, so let's quickly begin. So
In Linux, there are three types
of permissions that we are
going to give to any file or any directories.
Now these three permissions
are the first one is read which
is denoted by a symbol which is R.
The second one is right, which is
denoted by w.
And the third one is execute which is
denoted by X. It is not
denoted by E. It is denoted by X. So here
we know that we have three permissions read write
and execute X. All
right. So in Linux now, there are
three people to whom do
we give permissions?
Those are the first one is a user.
The second one is a group so user is
denoted by you. The group is denoted by
G and others which is
denoted by O So a user
is someone who has created a file the group
is for a specific list
of users who are in a group.
And all those people who are not the
user.
Who have not created the file or the people
who are not into a specific group. For example,
let's say there is an organization and all
the sales people are already added into
a group which is Sales Group. Now those who
get added into this group get specific
set of permissions. Those are
considered to be a group.
Now who are others others are who fall out
of this category? They are not into
the group which is the sales group. For example, or those
are not the people who have created the file, which
means they are also not the users.
Apart from these people everyone else is
others.
So I hope you guys understood who is others.
Perfect.
So now we need to give permission to these three people
user which is denoted by you group, which
is denoted by G and others who
is denoted by o
In Linux, you should know one thing that the permissions
are denoted this way for any file
or any directory, which is read right
execute hyphen. Read write
execute hyphen read write execute. The
first block is for the
user.
The second block is for the group and the
third block is for others. So this
is how the permissions are given
to user group and others.
now in the first block if it is
written as r w x that automatically means
that user has got the read
right and execute permission, which means the user
has all the permissions similarly the group
also have read write execute
which means it also has all the permissions
Similarly, others have rwx which
means it also has all the
permissions perfect. Now, let's go
to our terminal.
And let's try to see the permissions for
the file, which is X Y Z.
now here the command to see the permission is LS
hyphen all through which we
are getting the detailed information of a file
which we have created and the file name is X Y Z
Here you can notice the permissions that are being
given is.
R. W hyphen are hyphen
hyphen R dash dash
now here. You should understand the first
block.
Is for user the second block
is for the group third block is
for others as we have learned till
now. So this automatically means
that the user has read and write
permission. The group has read permission.
They cannot write and others
have only an only read permission.
Okay, so here we know that what are
the permissions that have been given remember there is
no execute permission given to anyone. Now.
What is execute you may ask? So in
case there are any scripts that need
to be executed then and
only then we need to give them the
permissions of execution or else they
will not run or will not get executed. Perfect.
So let's quickly see the user has
the read/write permission. So let's see who is
the user currently and the user is root. And
we also know that in the
detail of this file, which is x y z the
user who has created this file is root
and the group is also root perfect. So
now we know that the user is
able to read as well as write the file
and the user is root itself. So let's
quickly try and see if the user can read it.
By the command which is cat XYZ and
yes, the user can read the file because
the permission is given now let's try
if the user can write as well because
the permission is given of w, so, let's
quickly write into this file using the command Nano.
So Nano XYZ and here
we can see we are inside the file and we have modifying
it. So let's quickly write something which is this
is modified. Now, let's try to
save this. We have saved it and let's try
to read it now and see if our changes reflect
over there or no.
And here you can see we have successfully modified
the file which means the
permissions that are given are correct.
Now the group has the permission of read
which means anyone who
is into the group root can read this file.
And let's see the last permission which
is R which is only read which
means others who are not the
user root.
And who are not into the group root
or others?
So let's quickly try to add a user
so for that we are going to use a command which
is user ad and let's make a user named
urumi and let's also give a password for
that user which is udemy and I have set
at the password.
For this user let's quickly switch the user
by the command Su and now
we have switched the user. So now we are udemy.
So let's try to read this file and you have
seen through the permission that yes others
get the read permission. So that
is the reason we are able to read the file. Now. This
user is going to
try to write the file, which is
the W permission and we have seen that
the user does not have the right permission and
still he tries to write the file using the
command Nano.
And here you can see at the first place. There is
a error which says the file XYZ is
unwritable, but the user still
tries to write and he writes Modified by
udb and tries to save the file and it gives
a error which is permission denied. Which
means
Others which is the udemy user
cannot make changes to file because he
does not have the right permissions.
So let's quickly switch back to the main user which
is the root user who has made the file and
let's see if there are the changes that have
been done by the udemy user or no and here
we can see there are no changes done because for
obvious reasons udemy did not
have the right permissions to write into
the file XYZ as we have seen into
the permissions.
So I hope you guys understood what are Linux permissions
how it is given and how we have
to understand this permissions.
In case you have any doubts or queries, you can ask into
the Q&A section. Thank you.