groupdel

delete a group from the system

TLDR

Remove a group from the system by name
$ sudo groupdel [group_name]

SYNOPSIS

groupdel [options] group

DESCRIPTION

groupdel removes a group entry from the system. It modifies /etc/group and /etc/gshadow. The named group must exist. You may not remove the primary group of any existing user; the user must be removed first.Files owned by the deleted group retain their numeric GID but lose the group name association. You should manually check all file systems to ensure no files remain owned by the deleted group.

PARAMETERS

-f, --force

Force removal of the group, even if a user has it as their primary group
-h, --help
Display help message and exit
-R, --root CHROOTDIR_
Apply changes in the CHROOT_DIR directory and use its configuration files. Only absolute paths are supported
-P, --prefix PREFIXDIR_
Apply changes in the PREFIX_DIR directory. Does not chroot; intended for preparing a cross-compilation target

INSTALL

sudo apt install passwd
sudo pacman -S shadow
sudo apk add shadow
sudo zypper install shadow
nix profile install nixpkgs#shadow

CAVEATS

Cannot delete a group if any user has it as their primary group; the user must be removed first. Logged-in users who are secondary members won't lose access until their next login. Files owned by the group will show numeric GID instead of group name after deletion. Exit values: 0 (success), 2 (invalid syntax), 6 (group doesn't exist), 8 (can't remove user's primary group), 10 (can't update group file).

HISTORY

groupdel is part of the shadow-utils package, providing the standard Unix group management tools. It works in conjunction with groupadd and groupmod for complete group lifecycle management.

SEE ALSO

groupadd(8), groupmod(8), gpasswd(1), userdel(8), chgrp(1), groups(1)