How to Delete Group in Linux (groupdel Command)
2 min read
In Linux, groups are used to organize and administer user accounts. The primary purpose of groups is to define a set of privileges such as reading, writing, or executing permission for a given resource that can be shared among the users within the group.
A new group can be created using the
groupadd command. If a group is no longer needed and can be removed from the system.
This article explains how to remove a group in Linux, using the
groupdel Command Syntax
The general syntax for the
groupdel command is as follows:
groupdel [OPTIONS] GROUPNAME
GROUPNAME is the name of the group you want to remove.
Only the root or a user with sudo privileges can remove groups.
It is not possible to remove the primary group of an existing user without removing the user first.
groupdel command accepts only a few options that are rarely used. See the
groupdel man page for more information about the command’s options.
Deleting a Group in Linux
To delete(remove) a given group from the system, invoke the
groupdel command followed by the group name.
For example, to remove a group named
mygroup you would run:
The command above removes the group entry from the
On success, the
groupdel command does not print any output.
You can verify that the group is removed, by listing all groups using the following command:
getent group | grep mygroup
If the group you want to remove doesn’t exist, the system will print an error message like the following:
groupdel: group 'mygroup' does not exist
In Linux, you can remove groups using the
The same instructions apply for any Linux distribution, including Ubuntu, CentOS, RHEL, Debian, Fedora, and Arch Linux.
Feel free to leave a comment if you have any questions.