How to delete group in Linux using groupdel command

last updated in Categories , , , , ,

I am a new Linux system user and sysadmin too. How can I delete a group in Linux operating system using the command line option? How do I remove a group from Linux? Can you tell us command to delete group in Linux?

Introduction – The /etc/group file is a text file that defines the groups on the Linux system. There is one entry per line. Do not edit this file manually. You must use either use the groupdel command or delgroup command that modifies the Linux system account files, deleting all entries that refer to GROUP from the /etc/group file. This page shows how to remove a group in Linux.


How to delete group in Linux

  1. Delete a group named sales that exist on Linux, run: sudo groupdel sales
  2. Another option to remove a group called ftpuser in Linux, sudo delgroup ftpusers
  3. To view all group names on Linux, run: cat /etc/group
  4. Print the groups a user say vivek is in: groups vivek

Let us see some common examples in details.

How to remove group in Linux using groupdel command

The syntax for the groupdel command is:
sudo groupdel {group-name-here}
To delete a group named staff, enter:
sudo groupdel staff
One can view a list of groups on Linux using either cat command or grep command/egrep command and then we can use groupdel:
cat /etc/group
grep '^sales' /etc/group
egrep '^(users|root|sales)' /etc/group

Use the wc command to count number of groups in your Linux server:
wc -l /etc/group
Linux display group names
To delete a group called ftpusers, enter:
sudo groupdel ftpusers
Force removal of the primary group of a user by passing the -f option:
sudo groupdel -f admins

Deleting a group in Linux using delgroup command

In this example, you are going to delete a group named sales using delgroup. The syntax is:
sudo delgroup {group}
sudo delgroup --group {group}
sudo delgroup sales
grep '^sales' /etc/group

Delete group in Linux using delgroup command
Another option is to only delete if user/group is a system user/group. This avoids accidentally deleting non-system users/groups. Hence, we must use the same option:
sudo delgroup --system --group wwwusers
Want to backup files before removing any group? Try:
sudo delgroup --backup --group wwwusers

How to remove the user from a group

The syntax is as follows to delete the user named tom from a group called cartoons:
sudo deluser {user} {group}
sudo deluser tom cartoons

View config file

The file named /etc/deluser.conf contains defaults for the programs deluser command and delgroup command. One can use the cat command to see contains, enter:
cat /etc/deluser.conf

# /etc/deluser.conf: `deluser' configuration.
# Remove home directory and mail spool when user is removed
# Remove all files on the system owned by the user to be removed
# Backup files before removing them. This options has only an effect if
# target directory for the backup file
# delete a group even there are still users in this group
# exclude these filesystem types when searching for files of a user to backup
EXCLUDE_FSTYPES = "(proc|sysfs|usbfs|devpts|tmpfs|afs)"


This page explained the groupdel/delgroup commands that modifies the system account files /etc/group and others to remove the group. Please note that the given group must exist on your machine when you execute the groupdel command. The above commands works on all Linux distros such as RHEL, Fedora, CentOS, Debian, Ubuntu, Arch Linux and more. Please see the following man pages or read it online here:
man 8 groupdel
man 8 delgroup


Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Start the discussion at

Historical Comment Archive

1 comment

    Still, have a question? Get help on our forum!