So to manage permissions, the first thing to do
is to set file ownership.
How do you do that?
Pretty simple.
There's a chown command, chown for change owner.
It takes a mandatory argument of the user
that you want to make an owner, as well as the file.
And optionally, you can use colon followed by a group
to set user and group ownership using the same command.
Alternatively, there is chdrp.
Chdrp allows you to set group membership.
So it's followed by the group name and the name of the file.
Let me show you.
So let me create a directory to use as an example,
directory data.
I'm getting in there, and I'm using mkdir.
Let's call it files.
And now I use ls minus ld on files.
I do need the d to not see the contents of the directory,
but the properties of the directory.
And here we can see the standard that has been applied.
And the standard is that if a user creates
a file or a directory, the user will become owner.
And the primary group of the user will become group owner.
So as I'm root, and my primary group is root,
the file is owned by root root.
If I wanted to change that, I can use chown lindafiles,
for instance.
And now ls minus ld on files is revealing
that the directory currently is owned by user Linda.
And likewise, chgrp.
I don't have many groups, so let me use group wheel.
Doesn't make sense, but hey, just for the example,
ls minus ld on files is showing that the directory is currently
owned by user Linda and group wheel.
Now let me show you something funny.
I'm going out of here, and I'm using id.
And what do we see?
Well, we see I'm user student.
My primary group is the group student,
and my secondary group is the group wheel.
When I use touch file 1 and ls minus l on file 1,
what do we see regarding ownership?
It's owned by user and group student.
Now if I would use newgrp to temporarily change
my primary group membership, and I use touch file 2,
then ls minus l on file whatever is showing that this file 2
is owned by my new primary group, my temporary primary
group, that is.
Because as you can see in id, the group wheel
is listed first.
So in the sub-shell that I started while using newgrp,
wheel is my primary group.
And when I type exit and use id again,
I'm back in the primary shell, and we
can see that I'm back to student as my primary group.
So that is how you can manipulate group ownership
of files as well as directories.