Groupdel

From Unix SME

Command

 groupdel

Description

     The groupdel command allows removal of an existing group from the system. The group provided to this command must be an existing group, and deleting a group that is held by any user as a primary group is not allowed. This user must be removed, or have their primary group changed before deletion of the group is possible. Be careful; much like when users are deleted (and still own their previous files if they were not removed, or did not have their ownership changed), once a group is deleted everything that previously belonged to that group will still appear to belong to that group. If a new group is created with the same name, they will own the files that were previously owned by the deleted group.

Synopsis

 groupdel [options] GROUPNAME

Options

 -f or --force
  • This option forces deletion of a group, even though it may be the primary group of a user
 -P or --prefix PREFIX_DIR
  • This option applies any changes to the PREFIX_DIR directory, and also uses configuration files contained within the PREFIX_DIR directory.
 -h or --help
  • Using this option will display a valid list of commands and proper usage of this command
 -R or --root CHROOT_DIR
  • This option applies any changes to the CHROOT_DIR directory, and will also use configuration files contained within the CHROOT_DIR directory

Return values

There are 5 possible return values when the groupdel command returns from execution.

  • 0: Successful execution of groupdel command
  • 2: Invalid syntax upon execution
  • 3: This group cannot be deleted (does not exist)
  • 8: This group is the primary group of an existing user (cannot be removed)
  • 10: Unable to update group file

Examples

Example 1: Delete a group that is not the primary group of any user

 groupdel group1

Example 2: Delete a group that may be the primary group of a user

 groupdel -f group1
 groupdel --force group1

Example 3: Retrieve help menu for the groupdel command

 groupdel -h
 groupdel --help

Warning

Files and folders that belong to a group that has been deleted will still be owned by the group ID of the deleted group. If a new group is created with the same group ID, this new group will own all files previously owned by that deleted group.