Linux groupadd and groupmod Commands
In Linux, the groupadd and groupmod commands are used to manage groups. Below is a description of each command along with examples.
groupadd Command
The groupadd command is used to create a new group in the system.
Syntax:
groupadd [options] group_name
Example:
# Create a new group named "developers"
sudo groupadd developers
This command creates a new group called developers.
groupmod Command
The groupmod command is used to modify an existing group.
Syntax:
groupmod [options] group_name
Example:
# Rename the group "developers" to "devs"
sudo groupmod -n devs developers
This command renames the group developers to devs.
Options
-g GID: Assign a specific group ID (GID).-a -G GID: Assign secondary group ID (GID).-n new_name: Rename the group.
groupdel Command
The groupdel command is used to delete a group from the system.
Syntax:
groupdel group_name
Example:
# Delete the group "abhishek"
sudo groupdel abhishek
This command deletes the group abhishek.
Note: You cannot delete a group that is currently being used by any user or process.