How to delete group in Linux using groupdel command

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

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

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

🐧 Please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
2 comments… add one
  • 🐧 Vivek Gite Dec 30, 2018 @ 19:15

    The page has been updated to fix typos and images.

  • Anonymous Sep 16, 2020 @ 5:43

    How to remove multiple group using groupdel

Leave a Reply

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

Use HTML <pre>...</pre> for code samples. Problem posting comment? Email me @