The groupdel command will delete groups from the /etc/group file. It does not delete user accounts that are members of the group. Exercise caution when deleting groups as a mistake can cause users to not be able to access resources.
Syntax
The syntax of the groupdel command is:
# groupdel [options] {group names}
The groupdel command is generally used to delete a group from the system if it is not the primary group of any existing user. The following command line shows how to delete a group named geek from the system using the groupdel command:
# groupdel geek
Before doing this, it’s a good idea to identify all files that have their group ID set to the given group, so you can deal with them later:
# find / -group geek -print
because groupdel does not change the group ownership of any files. It simply removes the group name from the system’s records. If you list such files, you’ll see a numeric group ID in place of a group name.
If you encounter below error while running the groupdel command:
groupdel: command not found
you may try installing the passwd package as shown below as per your choice of distribution.
Distribution | Command |
---|---|
Debian | apt-get install passwd |
Ubuntu | apt-get install passwd |
Alpine | apk add shadow |
Arch Linux | pacman -S shadow |
Kali Linux | apt-get install passwd |
Fedora | dnf install shadow-utils-2 |
Raspbian | apt-get install passwd |