groupdel command in Linux operating system

groupdel command in Linux operating system

In this article, we are going to show you that how to Use the groupdel command in Linux. If you want to learn the basic of the groupdel command in Linux then this article is ideal for you.

In the Linux operating system, groups are used to organize user accounts. You can create a new group using the groupadd command. If you have a group and it is no longer needed then you can removed it using groupdel command from the system. groupdel command will delete all information and entry that is refers to the group.

groupdel Command in Linux

In the Linux, the basic syntax of the groupdel command is show as below:

groupdel [options] GROUP

Here GROUP is the name of the group that you want to remove.

Files:

  • /etc/group : It is contains the account information of the Group.
  • /etc/gshadow : It is contains the secure group account information.

In the linux, the root or a user with sudo privileges only can remove groups. It is not possible to remove the primary group of an existing user without removing the user first.

Deleting a Group in Linux

To delete a group from the Linux system, simply run the groupdel command with the group name :

$ groupdel mygroup

When you run the above command, it will removes the group entry from the /etc/group and /etc/gshadow files.

To verify that the group is removed or not, run the below command to listing all groups :

$ getent group | grep mygroup

The system display a error message if the group that you want to remove doesn’t exist.

Output

groupdel: group 'mygroup' does not exist

Options:

  • -f –force: Delete group even if it is the primary group of a user.
  • -h –help: Displays the help message and exit.
  • -R –root: Directory to chroot into.

Exit values: groupdel command exits with the following values.

  • 0: Success
  • 2: Invalid Command Syntax.
  • 6: Specified group does not exist.
  • 8: Can not remove users primary group.
  • 10: Can not update the group file.

That’s all

If you face any error and issue in above steps , please use comment box below to report

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.