In this video, we'll talk about creating groups.
Creating groups requires GroupAdd. It's pretty simple. Use groupadd followed
by the group name to create a new group.
And if you want to add users to a group as a secondary group,
then you use user mod ag, group name username. Now, what is this ag
about? Well, user mod G requires you to specify a list of secondary groups.
This list of secondary groups will override all current secondary group assignments. So if you
want to add users to a new secondary group without removing them from currently existing
secondary groups, you use user mod ag on the group name. Let me demonstrate.
So let's start with ID on user Anna. And we can see that user Anna is a member of the group 1004.
That's a private group.
Now I'm going to use sudo group add sales.
And then I'm going to use sudo
user mod a uppercase g sales Anna.
So now let's do ID Anna to figure out what user Anna has as configuration.
So user Anna is a member of group Anna as well as group Sales.
Now let me show you the wrong approach. I'm
going to use user mod g wheel for Anna.
And then I'm repeating my I.D. anna. And look at that, she's no longer a member of the group sales.
That is why we really needed this.
A for append and g for uppercase g. And that will make sure that the
user is added to the group without overwriting any of the existing group memberships.