Introduction
In this lab, you will learn how to manage user groups in Linux. You will learn how to create, delete, and manage user groups.
Achievements
groupadd
- create a new groupgroupdel
- delete a groupgroups
- list groups a user is in
In this lab, you will learn how to manage user groups in Linux. You will learn how to create, delete, and manage user groups.
groupadd
- create a new groupgroupdel
- delete a groupgroups
- list groups a user is inIn this step, we will learn how to show user groups. We will use the groups
command to show the user groups.
The syntax is:
groups [options] username
List the groups for the root
user:
groups root
root : root
List the groups for the current user:
groups
Sample output:
labex sudo ssl-cert public
groupadd
is used to create a new group. The group name must be unique. The group name must start with a letter and can contain letters, digits, underscores, and hyphens. The group name must be 32 characters or less.
The syntax is:
groupadd [options] groupname
Create a new group called devops
:
sudo groupadd devops
Verify the group was created:
tail -n 1 /etc/group
Sample output:
devops:x:5003:
groupdel
is used to delete a group. The group must not have any members.
The syntax is:
groupdel [options] groupname
Delete the devops
group:
sudo groupdel devops
Verify the group was deleted:
tail -n 5 /etc/group
You can see the devops
group was deleted.
Congratulations! You have successfully completed the lab.
Linux user and group management is an important skill to have, especially if you are working in a Linux environment. You need learning how to create, delete, and manage users and groups.
Keep learning!