Linux Commands

How to Delete Groups with groupdel Command in Linux

The “groupdel” command in Linux removes the account from Linux. It provides a way for administrators to remove a group and its associated permissions, making it no longer accessible for users or processes.

Using this command, we can manage and delete users that we no longer need. Here we will create a group of users and then delete it using the groupdel command.

How to Delete Groups with groupdel Command in Linux

To list all the groups run below-mentioned command:

$ tail /etc/group

Here we can see group1 displayed which we just created.

How to Delete a Group Using groupdel Command

Now to delete a specific group we will use the below-given command. For example, to delete the group1 from list run the groupdel command:

$ sudo groupdel group1

Once the group is deleting again, list all groups to confirm the deletion. Now again run the /etc/group command:

$ tail /etc/group

Here we can see the group1 is successfully removed using the groupdel command.

For example, if a certain group doesn’t delete, the “-f” flag will forcefully delete this group. To delete group1 using the “-f” flag, run the below command:

$ sudo groupdel -f group1

The grep command can also confirm whether a certain group is deleted or not.

$ grep '^group1' /etc/group

If no output is displayed on the terminal, it means the group is already deleted.

For more info about groupdel run the given command:

$ sudo groupdel -h

Conclusion

The Linux “groupdel” command is a powerful tool for managing group accounts on a Linux system. It enables administrators to remove groups that are no longer needed, ensuring the security and efficiency of the system by reducing the number of unneeded access controls.

About the author

Kashif

I am an Electrical Engineer. I love to write about electronics. I am passionate about writing and sharing new ideas related to emerging technologies in the field of electronics.