Now, of course, we also have group management.
And we've got the groupadd command, the groupmod command,
and the groupdel command.
However, there aren't that many properties of a group.
So often, we only use groupadd and groupdel.
Here we're adding the marketing group,
and then we can go through and modify a user to add them to a group.
Don't forget, if we are appending new groups to a user,
then we can use the ‑a command so we append.
Let's go out to our command line now so we can look at working with our groups,
looking at creating our groups, and adding users into those groups.
If I go through and take a look at the ID for the vagrant user,
we can go through and see where the vagrant user at the
moment doesn't have any additional groups.
And in the same way, when I go through and look at,
let's say, id u99, we've just created that user.
We don't have any additional groups for that user either.
Using our groupadd command, we can go through and create a new group,
and it really is quite simple.
Let's go through and create our marketing group.
Let's go through and maybe create our sales group.
So we've got two new groups.
These groups themselves are going to be stored inside of our group file.
We can look at it in two ways.
We getent and then group.
Well, we can then go through and list out our group file.
But of course, this is just a file in our filesystem,
so I can go through and look at then the /etc/ and then group file.
So the information is very, very minimal that we have there.
Let's clear out my screen.
Having carefully crafted these groups,
we can carefully craft them into our users group membership.
So using our usermod command, we're actually modifying a user,
the G changes the complementary groups, or our secondary groups,
where we can add in the sales group to the user u99.
Checking with the id command, we can see then that we belong,
or u99 belongs, to the group u99 and sales.
So boosted by this,
we might then suddenly add in the marketing group to our user as
well and then be terribly disappointed to see that we only have
marketing and the primary group u99.
Well, we are overwriting the group list,
so we must remember to use the a, for append,
if that's what we want to do.
So now as we go through and append the sales group,
we should hopefully find that we've got both the
sales group and the marketing group, which we do.
But do be aware,
it could be very easy to overwrite group membership here and then perhaps not
have a good idea of what groups that user should belong to.
It becomes very easy to delete groups.
We've got the groupdel command, and we can then go through,
maybe delete the sales group.
But we don't have to be concerned about going back through all
of our users because removing the group removes all trace of
membership of that user to the group.
The membership is maintained by the etc and group file as far
as secondary group membership is concerned.
So it's a very straightforward way of just removing our group without
leaving any residue of that group ever having existed.
But let's return now to our slides so we might summarize just a little of what we've looked at in this user management module.