File ownership in this lesson, we will cover how files and directories are owned and how we could change
the ownership of those files and directories.
So the file ownerships are created on user level and a group level.
There are two owners of a file or directory, a user, the one who creates the file or directory, and
the second one is a group.
The user, the group that belongs to if you are if you belong to two different groups and the permission
applies that the second group has agreed permissions, or you could delete a file, a directory as long
as you in that group, then you will have the right command to change file.
Ownership is change own, which is also known as chain owned and change group H group change on changes.
The ownership of a file change group.
Changes to group ownership of a file.
Recursive ownership change option, if you are using an option with change own or change group with
minus uppercase, or it will not only change that directory, but also all the files and directories
within that parent directory.
If you look at the example of windows that say we have this folder called videos and when I click.
When I do right click and go to properties, you'll see that under security, this file is owned by
the systems and I afsal an administrator.
So you see these two people here.
These are the group and the single user.
One person here is just the user.
And again, the system is a group.
So group system and administrator on this file or folder called video.
And the user who created their folder is I have TSOL and you see at the bottom it tells you whether
that user has read write executable permission.
You can see right here it has all the permission that we talked about.
In our Linux machine when we log into our Linux machine.
Again, the first thing that we do is see who we are.
So we are ourself, see what files are directories we have.
These are all the listing of files and directories we have now here.
And the first, second and here, the third column, the third column tells you who owns this file.
Let's say we go to Lisa.
We created this file, Lisa.
And the person who owns this file, Lisa, is the user I have or you sell yourself in this case.
The fourth column right here is the group name in this case is I absol again, because I am part of
my own group.
I belong to my own group.
I could change that to a different group, but since I'm a regular user, not a super user, I won't
be able to change that permission to any other group.
The only person or the only account that could change that ownership is route.
So let's become route Sue.
Dash.
Once you log in, you do TWD and here it will bring you into kashrut.
Now remember, you are not in your home directory.
You are in rude territory because you are rude right now.
So I want you to go to your home directory, which is she remember, slash home.
And slash your username.
It will take you to your home directory, you could just hope to confirm and duelist Manaslu TIAR to
confirm and at the time that these are your directories and files, if you wanted to change the permission
of Lesa and you wanted to change it from yourself and you wanted to have this owned by route, which
you will do as change own.
And you specify the name of the user you want to change to.
And the name of the file, Lisa.
And then when you do this minus all to your ear, you will see right here.
The file is now owned by a route you could also do just to be more specific, so you don't see all of
the files.
You do this mysel, Lisa, and you'll see here now the file is owned by a route.
You could do the same thing when you do S.H. GAAP, which is to change the group, you could do the
group.
Also, there was another group called Route and you could do this again and verify it.
And now you'll see this file.
Lisa is owned by a route and and the group who owns this file is also route.
Now, what happens when you become yourself again?
How do you get out of this route account?
You just simply type exit.
You are logged out and just confirm who you are.
You are yourself whose territory you are in your new home directory dweller's mysel tr and you see.
There was this fall.
Lisa, now what happens if you try to delete this file?
Let's see our friend Lisa.
I will tell you, remove right protective of empty file.
If you say yes and do this myself here.
There you go.
It is gone.
The reason it is gone now why is because when you go one step back to your home directory, so your
home is right now is slash home, slash yourself.
And when you go one step back.
You are in just slash home and do less mysel here, you will see the eye of directly, which is your
home directory has the permission of yourself to read, write and execute, meaning anything inside
of the director.
You can read, you can write and you could execute to regardless if whoever puts the file in, whoever
owns the file.
Or who whichever group owns that you could go ahead and still delete it now if you try to create a file
in, let's say, ETSI.
And you go touch.
Test fire.
It would tell you permission denied because you do not have permission to write to this file.
How do you check that you do?
Ls my nacelle slash?
You could do that or you could simply go to seed, slash and sell and you'll see here's a list of all
the directories that are inside of Slash and the one we were trying to go to is Etsy.
If you notice, the Etsy is owned by route and the group is owned by a route as well.
Now, the route has the permission to write to it.
But what about the people who are in route group?
They don't have a permission to write it.
What about everybody else?
They don't have a permission to write to it.
So that is why you cannot create a file in Etsy.
So let's let's see if we become rude again.
OK, and now you go to ETSI.
And you create a file touch test, one, two, three is verified, a less Manaslu TR.
You see, the bottom is your file.
Now, another way, what you could do is while we're working on this, you can minimize this window
and you could open another window by right.
Clicking and clear open terminal.
So this way, we have a regular account, which is our account and the route account.
So this way we don't have to exit out of a full account.
So we are.
We are, as always, which direction we are in, we are in session and we created the file in ETSI,
right as a rule.
So let's go to ETSI and let's see what else might have settled here.
And now we're going to try to remove this file test.
One, two, three.
And it's going to say remove.
Right.
Protected.
It's just a warning usage.
Yes.
And it's still says permission denied.
Now why it's saying permission denied.
Again, you go to a slash and you do X minus L and you will see right here, that's Etsy directory.
And it'll tell you right here, the group Ribot's do not have write permission and the other three bits
do not have write permission as well.
So that's how you change these user.
The files, ownership and group ownership of the two commands that we learn is change.
Ownership, which is C, H, o and W o, w, n and the second one as change group.
So again, really want you to do a man on each command.
And go over the description, the different option it has.
Same thing you do with the with a second command as well.
And also I want you to practice this command by changing the mission only in your home directory.
So your home directory is.
Slash home, slash yourself, and you could try changing permission to one of the directory, like create
a new file.
Don't touch the files that you created and just the permission and test file.
Create this file and just practice your change ownership and change group command on this file and see
how you could change it.