Linux groupdel command

Updated: 04/26/2017 by Computer Hope

About groupdel

Used by a superuser or root to remove a group.

Conditions

You may not remove the primary group of any existing user; you must remove the user before you remove that user's primary group.

You should manually check all file systems to ensure that no files remain owned by this group. groupdel will not automatically check for files owned by the deleted group.

groupdel syntax

groupdel group

Configuration

The following configuration variable, located in /etc/login.defs, changes the behavior of groupdel:

MAX_MEMBERS_PER_GROUP (number)

Maximum members per group entry. When the maximum is reached, a new group entry (line) is started in /etc/group (with the same name, same password, and same GID).

The default value is 0, meaning that there are no limits in the number of members in a group.

This "split group" feature is primarily used to limit the length of lines in the group file. This is useful to make sure that lines for NIS (Network Information Service) groups are not larger than 1024 characters.

If you need to enforce such limit, you can use 25.

Note: split groups may not be supported by other tools and programs. You should not use this variable unless you really need it.

Exit Values

The groupdel command exits with the following values:

0

success.

2

invalid command syntax!

6

specified group doesn't exist.

8

can't remove user's primary group.

10

can't update group file.

groupdel examples

Tip: For this command to work you must have superuser rights or be logged in as root.

groupdel newgroup

In this example, the groupdel command would delete the group newgroup.

gpasswd — Administer /etc/group and /etc/gshadow.
groupadd — Add a group to the system.
groupmod — Modify a group definition.