File permissions in this lesson, we will learn how you could change the permissions of your files and
directories this way you are protecting your environment, your files and your directories from being
viewed by other users are being deleted by other users.
Unix is a multi-user system, every file and directory in your account can be protected from or made
accessible to other users by changing its access permissions, every user has a responsibility for controlling
access to their files.
Permissions for a file or directory may be restricted to buy it types.
There are three types of permissions read, write and execute.
I'm sure you know, read and write.
What does it mean to execute?
If it's a program, if it's if a file itself is a script or a program, it has an X permission, which
is executable, not everybody is allowed to run a certain permission.
So if a user is allowed to run a program, they would have an executable permissions to it.
It permission, which is required in executable, can be controlled at three different levels, at a
user level, which is yourself at a group level, can be people in the same project or group or a same
department or others like everyone else.
File or director permission can be displayed by running Ellis minus L Command.
So you will see here at the bottom, you see red, white, x, the first bit shows that it's.
It's a while the the the next three bit shows it has read right and executed with permission by the
user, the second three bits are for the group and their three bids are for the others.
Command to change the mission is change mod a lot of times it's also referred to as CHMOD.
So let's look at our Lennix machine, so this way I'll better explain to you how permission works.
Again, the first step you always do is to check who you are.
You are yourself which director you are in and you are in your home directory, and when you do else,
this command will show you documents and folders and files, but it's not going to show you the details,
whether it's a directory, what permission it has or what the size of it.
So what's the option we use?
I'm sure you know this by that and by now at minus L or L tr or whichever you prefer.
So when you do a list minus L, you see the listing of all the files with all its details.
Now let's pick one file.
Let's pick.
Will pick, Gerri, we also use the option.
Alice Mianus El.
Jerry, here, you see.
The first bit.
Right here, Dasch, this one refers to as it's a file, the second three bits referred to as read,
write and execute.
Now, this shows the user I ASOL, which is myself who created this file, has only read and write permissions.
I do not have executable permission.
It means I this file is not a script.
That's why it does not have executable.
There was a script that it would have next to it.
So I have me myself as I have, has a right and a right to read the file and write to write to it.
The second group who owns it, who has a permission is right here is.
R. W..
And again, Dash, which means the group, which is the group itself, is also Afsal also how are W
and Desch?
And the last one is other.
These lasy permissions is that the others are can only read this while they cannot write to it or they
cannot delete to it.
So these are the permissions at the level of user group and others.
Now let's take the command to change these file permission.
What's the command to change the file system?
Is change marred again every time you are learning a new command?
I will highly recommend you that after the lesson you run man and see mode they followed by the command
name.
This will give you all the details about the command, what it does, what options it has with the commands
are used for and so on.
So I'm going to use S.H. MODIS.
Command and I what I wanted to do right now is I want to have the group right here, these three, but
I want this group to not have the w the right permission.
So I will do as G as a group minus W and finally, Jerry.
So what I'm telling the operating system to do is remove the right permissions from the file name Jerry.
Again, this shows that I have a command right here and these are my options and these are my arguments.
So once I execute that.
He'll give me my prompt back and when I do less.
Minus LTA, minus L, Gerri, and you will see right here now, there is no right permission.
So anyone in the group of Tzahal can not write to this far.
They can still read it, but they cannot write to it.
Now, I want to remove their read permission from everyone.
So the command to do that is S.H. mode.
And if you want to do for everyone, the Jews use a as for all minus.
Ah, and which file are you working on, you are working on Cherry, so you hit enter and you do X minus
Alti or or just in cherry.
You will see no one has read permissions.
Now we only have the right permission by the user.
I have so I want to remove that right permission as well.
So what do C.H. Amadi and now which option am I going to use?
I'm going to use you as user.
Remember, we have three different groups, three different ways.
We could change it right here.
Each permission can be controlled at three levels.
You G and O.
So I'm going to use you as because you as myself, minus W Jerry.
To verify, fight again, you do it as myself, Gerri, and there you go.
Now, you could tell by looking at this file that it has no permission.
So even myself, if I wanted to delete this file, I cannot delete this file.
Let's look at R.M. to remove a file, Gerri.
It will say, remove my protect your empty while it is giving me the warning sign that you this is right,
protected if I say yes than ever and more because since I'm the owner, actually, but it does give
me a warning sign so I don't want to remove it.
I'll just say no.
And then if I wanted to read a file to read a file, you could use the command card, which I will cover
later on.
But for this lesson, I'll just tell you, Gerri, we could do the read and I will see it says permission
denied.
Why is that?
Because I don't even have a read permission to read the file.
So I wanted to give back all the access that all the permissions that I had at the beginning.
Right here is the file.
And I wanted to give back all the permissions.
Let's start with the first user, Sciascia Modise, and the user is you and I wanted to give plus because
I'm adding permission, I want to give Reed and W.
And Jerry.
Let's see if it has the permission to one, yes, it has it now, the user has it now, wanted to give
this group the same thing.
So what do you do, by the way?
You could run up Parakey.
To go back to the last command that you typed, so this in this case will just replace you with G hit
enter.
Let's check it again.
And there you go, we, the user has it rewrite the group, has it read right, but others don't have
anything.
Well, when we created the file, others had to read permission.
So I wanted to assign to others as well.
So the command to do it is changed.
Mod others plus read Jerry.
Let's try again to see if it worked and it did.
Now we got all the permissions back.
Now this same command works and a directory works on a link and works in a file you could use on anyone.
So these are the three permissions that you can see.
You have this permission column, the first column.
In your El's minus output, this would tell you what kind of permissions you have now, what if a directory
has this executable right here?
Does that mean the directory is a script?
No.
The reason it means X here is because you could KDDI into that directory.
That's why you have X in the directories.
So if I have this directory called Seidenfeld, I could do KDDI Steinfels and I could log in to I could
actually get into the same file directly.
Now let's go one step back and do less minus L tr again.
And now I don't I want to take away the permissions to for everyone to go into their directory.
So what do I do.
Change mod.
I want everyone so a minus executable cipher.
So now when you do list myself here you'll see this directory has read right.
But no executable rewrite.
No executable read write.
No read, no executable.
No right.
So can I add CD into the directory now.
I don't know.
Let's see Cricinfo.
Permission denied.
All right, why?
Because we don't have executable right to that directory, we have to have an executable right to copy
into that directory.
So let's assign the permission back.
All plus X Sinophile.
And this check again and you will see the sign at the bottom now has executable, executable and executable.
This is how you could protect your files and directories from being manipulated or being deleted even
by accident.