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, write, 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, write 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 RW X, 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 RW hyphen, ah, hyphen, hyphen, ah,
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 until 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 and 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 X, Y, Z, 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 off.
W So let's quickly write into this file using the command nano.
So nano x, y, z and here we can see we are inside the file and we are 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 our which is only read, which means others who are
not the user root and who are not into the group root are others.
So let's quickly try to add a user.
So for that we are going to use a command which is user read and let's make a user named Udemy and let's
also give a password for that user, which is Udemy and I have set the password for this user.
Let's quickly switch the user by the command issue 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 an error which says the file x, y, z is unreadable,
but the user still tries to write and he writes modified by Udemy and tries to save the file.
And it gives an 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 are being done by the Udemy user or no.
And here we can see there are no changes then, because for obvious reasons Udemy did not have the right
permissions to write into the file X, Y, Z, 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
these permissions in case you have any doubts or queries you can ask into the Q&A section.
Thank you.