In my previous article, I had explained how to create a Group in Linux. If you have not read that article, I would suggest you to read that guide.
Today you will learn how to delete a Group in Linux using the groupdel command.
You have to run the
groupdel command as a root user because upon running this command, it makes changes to the following important configuration files whose owner is root.
As I already mentioned If some permission or policy is to be enforced for users, we cannot manually apply the permission to each user and this is not the right way to do it.
Therefore groups are used in such situations. You can also delete the group when the need is over.
So let’s get to the topic.
You must follow the syntax given below to use the groupdel command.
groupdel [options] GROUP
1. How to Delete a Group
To delete an existing group in Linux you can run the groupdel command.
Here in this example, I am deleting a group named group7.
# groupdel group7
As soon as you delete a group, the
groupdel command removes entries of that group’s name from the
If you are trying to delete a group that does not exist then you will get this error.
# groupdel group7 groupdel: group 'group7' does not exist
2. Delete the primary group of a user
You can forcefully delete a user’s Primary group. To do this you can use the
-f option with the groupdel command.
The system will display this error message when deleting any primary group without using the
In this example, I am trying to remove the primary group named shrikant.
# groupdel shrikant groupdel: cannot remove the primary group of user 'shrikant'
In this case, you have two options to delete a group and that is,
Either change the user’s primary group and then delete the group. To do this you can run the following command.
# usermod -g group1 shrikant
Suggest Read: Modify an existing user account in Linux
Or type the following command to forcefully delete the group.
# groupdel -f shrikant
3. Help/Manual page access
Use the following commands to access the Manual Page/Help Page of
# groupdel --help
# man groupdel
You can visit at following websites to get more information on
I hope you have learned something from this article.
I have tried my best to include all the features of groupdel command in this guide.
Now I’d like to hear your thoughts.
Was this guide useful to you?
Or maybe you have some queries.
Have I not included any command in this guide?
Leave a comment below.
Here are a few other hand-picked guides for you to read next: