In this video,
we're going to discuss how to create, modify,
and delete user groups.
In order to gain access to users in a more efficient manner,
you'll need to create groups for users to be a part of.
This means that groups associate user accounts
that have similar security requirements,
and we can then assign rights and permissions to the groups
instead of directly to the individual users.
Just like user accounts,
groups can also be modified and deleted when needed.
Groups simplify administrative tasks,
and they're represented on a system by a group ID number.
Users can also be a member of more than one group.
For example, on my network,
I'm a member of the administrator's group.
I'm also a member of the instructor's group
and the accounting group,
because I fill all these various work roles
and responsibilities within my company.
As an administrator,
you're commonly going to reference the /etc/group file
to find information about groups on your system,
because it's the storage location for all of the groups.
Each group is going to contain four fields of information
separated by a colon.
First, you have a Group Name.
Second, you have a Password.
Third, you have the Group ID.
And fourth, you have the Group List.
The group name refers
to the user friendly name of the group.
For example, you might find a group called instructors
on my company system.
The password field refers to the password
that's being required to enter this group.
The group ID refers to the reference number
of the system for the group.
And then we have the group list,
and this refers to the group members
that are part of this group.
By default, the group list will be empty,
because a new group has no members when you first create it.
Now, the proper way to edit the /etc/group file
is to use the groupadd, groupmod, or groupdel commands.
The groupadd command is going to create the group.
By default, the group has no members and no password.
Then we have some groupadd options that we can use.
This will allow us to modify this group.
Now by using the option -g,
you can create a group
with a friendly name or a group ID.
By using the -f option,
you can exit with a success status
if the group already exists.
If you use the -o option,
this is used to allow a group to be created
with a non-unique group ID.
The proper way to use the groupadd command
is to enter groupadd, your options,
and then your group name.
For example, I could enter groupadd -g 100 instructors.
This will create a new group called instructors.
Manually editing the /etc/group file is not recommended,
because a typo or other mistake
could render your system unusable.
Instead, you should modify it using the groupmod command.
This will allow you to change the group's own attributes.
By typing -g, you can change the group ID.
By typing -n, you can rename the group.
The proper way to use the groupmod command
is to type groupmod, your options, and then your group name.
Over time, you may find that you need to delete
some of your older groups.
The groupdel command can be used to delete the groups
that you no longer need.
Note though, the groupdel command
will not delete the user accounts that are members
of those groups being deleted.
It only deletes the group itself.
Always be careful when you're deleting groups,
because a mistake here can cause the users of the groups
to no longer be able to access resources
that they need to do their jobs.
The proper way to delete a group
is by entering groupdel, the options,
and then the group name.