To make managing security easier, users are a member of groups.
And for file system permission purposes, each user must be a member of at least one group.
That is because if a user creates a new file, the user will become owner and the primary
group of that user will become a group owner of that file.
Primary group membership is managed through etcpasswd.
And additional secondary groups can be defined as well to give users access to additional
features.
One example that we have already seen is to make sure that the user is granted sudo superpowers.
Make them a member of the group wheel and it's taken care of.
Secondary group membership is managed through etcgroups, but you won't notice if you are
managing your groups the right way.
Also, you can temporarily set primary group membership using newgrp.
And you can use id to see which groups a user is a member of.
Let me demonstrate.
So I'm first going to use id on Linda.
Linda is my sudo user.
Oh no, she's not.
Okay, then I'm going to do this on user student.
And user student is a member of the group wheel.
So let's get back to the user student shell.
Now how about this ownership?
Let me use touch owner, which creates an empty file with the name owner and ls-l on owner.
It's showing that user student is user owner, group student is group owner.
Now if I'm using newgrp wheel and I use touch newfile, then what is happening?
Well, let's check it out.
You can see that newfile is owned by group wheel.
And that is because I temporarily have used newgrp to set my primary group membership.
So when I type exit and I use touch newfile, well, then I'm back in the original environment
where user student is a new primary group.
That's all for now.
In the next video, you'll learn how to work with groups and how to add groups and make
users members of these groups.