45. Group Management - Creation, Modification and Deletion
Contents
To make it easier to manage groups, linux provides some common commands that allow you to add, delete, and modify groups in a more standardized way.
Add Group
We can add groups through the groupadd command.
Here are some common options for groupadd command:
Option | Meaning |
---|---|
-g or ‑‑gid | Specify the group’s ID. The specified value must be greater than or equal to the value of the GID_MIN variable in the /etc/login.defs configuration file and less than or equal to the value of the GID_MAX variable in the same file. |
-r or ‑‑system | If this option is specified, the created group is a system group. The system group’s id range is between the values of the SYS_GID_MIN and SYS_GID_MAX variables in the /etc/login.defs configuration file. |
Add Groups
Let’s add new groups:
|
|
Modify Group
We can modify the group information through the groupmod command.
Here are some common options for groupmod command:
Option | Meaning |
---|---|
-g or ‑‑gid | Specify the group’s new ID. |
-n or ‑‑new-name | Specify the group’s new name. |
Modify Group Name
Let’s modify the group’s name:
|
|
Delete Group
Let’s delete the group:
|
|
Group Password
We can use the gpasswd command to specify or change the login password for the group.
Here are some common options for gpasswd command:
Option | Meaning |
---|---|
-a or ‑‑add | Add the user to group. |
-d or ‑‑delete | Delete the user from group. |
-r or ‑‑remove-password | Remove the password from the group. |
Create Password for Groups
|
|
New Group
With the newgrp command, we can have the user log in to another group.
Log in to Another Group
Log in and log out of another group:
|
|
References GROUPADD(8), GROUPMOD(8), GROUPDEL(8), GPASSWD(1), NEWGRP(1)
Author Dong Chen
LastMod Sun Mar 17 2019