How to Remove a User from the sudo Group

To revoke sudo privileges from a user, you must remove them from the sudo group. Below are the methods for different Unix-like systems:

Ubuntu and Debian-based Systems

Using gpasswd

sudo gpasswd -d username sudo

Using deluser

sudo deluser username sudo

CentOS, Fedora, RHEL, and Similar

These systems often use the wheel group for administrative privileges:

Using gpasswd

sudo gpasswd -d username wheel

Using usermod

sudo usermod -G $(groups username | sed "s/ wheel//g") username

General Method

sudo usermod -G $(id -nG username | sed 's/\\//g' | tr ' ' ',') username

Confirming Removal

After removing a user from the group, verify with:

groups username

Important Considerations