Linux - groupadd / groupdel in Linux
In Linux, groups are used to manage permissions for multiple users at once. The commands groupadd and groupdel help you create and delete groups in the system.
1. groupadd
The groupadd command is used to create a new group.
Basic Syntax
groupadd groupname
Examples
Create a new group
groupadd developers
Create a group with a specific Group ID (GID)
groupadd -g 1050 staff
Create a system group
(System groups have lower GIDs, usually below 1000)
groupadd -r sysgroup
2. groupdel
The groupdel command is used to delete an existing group.
Basic Syntax
groupdel groupname
Example
Delete a group
groupdel developers
Important Notes
-
You cannot delete a group if it is the primary group of any user.
-
You must change the user’s primary group before deleting it.
-
Deleting a group does not delete the users in it; it only removes the group entry from the system.