When you have a user group that you no longer need, you might want to delete that user group. There are several ways to do that in Linux. Here, I will show you two of them, which are almost similar: using groupdel and delgroup commands
groupdel commandTo delete a group, execute:
$ sudo groupdel groupToDeleteYou can remove the primary group of a user by passing the -f option to the groupdel command. For example, you can remove the admins group:
$ sudo groupdel -f adminsCheck that the group has been removed:
$ grep '^groupToDelete' /etc/groupdelgroup commandTo delete a group, execute:
$ sudo delgroup groupToDeleteCheck that the group has been removed:
$ grep '^groupToDelete' /etc/groupAnother option is to delete an user group only if it is a system user group. This will help you to avoid accidentally deleting non-system user groups. To do that, you must use the --system option:
$ sudo delgroup --system --group groupToDeleteIf you want to backup the files before removing an user group, use the --backup option:
$ sudo delgroup --backup --group groupToDeleteUse the following command to remove an user from a group:
$ sudo deluser userToRemove groupName