Remove User from a Group Using “gpasswd” Command in 3 Steps

In Linux, groups are a way to control access and share resources where different groups enjoy different privileges. An administrator can remove a user from a group for different reasons as changing job responsibilities, security concerns etc. The gpasswd command is a powerful tool to add or remove a user and manage group passwords. In this article, I will show you how to remove a user from a group using the gpasswd command in Ubuntu.

Key Takeaways

  • Viewing the groups of a user.
  • Removing a user from a group.


Process Flow Chart

Distro Used Throughout the Tutorial: Ubuntu 22.04.1 LTSProcess flow chart to remove a user from a group using the gpasswd command

Watch how to Remove a User from a Group using the ‘gpasswd’ Command

3 Steps to Remove a User from a Group using the gpasswd Command

In my Ubuntu, there is a user by the name of “walid” and he is in a group named “mygroup”. Now I will remove user “walid” from the “mygroup” group using the gpasswd by the following three steps.

Step 01: View Current Groups in Ubuntu

In the beginning, I will check the current groups of the user “walid”.

Steps to Follow >

➊ Launch an Ubuntu Terminal by pressing CTRL+ALT+T.

➋ Insert the following command:

groups walid
  • groups: Allows to view and manage groups.
  • walid: Name of the user.

Showing current groups of the userThis shows the groups that the user “walid” joined. Also, there is a group “mygroup” and I will remove the user from that group.

Step 02: Remove the User from a Group in Linux

In this step, I will use the gpasswd to remove the user “walid” from group “mygroup”.

Steps to Follow >

❶ Copy the command below on the Ubuntu Terminal:

Command Syntax >

sudo gpasswd -d USERNAME GROUPNAME
sudo gpasswd -d walid mygroup
  • sudo: Grants root privileges.
  • passwd: Adds or removes users and manages group passwords.
  • -d: Deletes user.
  • walid: Name of the user.
  • mygroup: Name of the group.

❷ Provide the password (if necessary).

❸ Press the ENTER button from the keyboard.Removing user from a groupIn the output, you should see something like “Removing user walid from group mygroup”.

Step 03: Check if the User is Removed Successfully in Linux

Finally, I will check if removing user “walid” from group “mygroup” was successful.

Steps to Follow >

➊ Write the following command on the terminal:

groups walid
  • groups: Allows to view and manage groups.
  • walid: Name of the user.

➋ Hit the ENTER key from the keyboard.Groups after removing user from a groupIf you look carefully, you will see there is no group by the name of “mygroup” here. So I have successfully removed user “walid” from group “mygroup”.


In this article, I have tried to show you how to remove a user from a group in Ubuntu in a simple and comprehensive way. I hope you find my effort helpful.

People Also Ask

What is gpasswd in Linux?
The gpasswd is a command that is used to administer groups in Linux. It writes group information in /etc/gshadow and /etc/group files. Using this command, an administrator can define group administrators and members.

How can I delete my group members?
There are multiple ways to delete a user from a group. However, the best approach is using the gpasswd command with option -d” like below

sudo gpasswd -d USERNAME GROUPNAMR

How to remove a password from a group in Linux?
You can use the gpassword to remove passwords from a group. To do that, you need to use the option -r”. For instance, you have a group named “mygroup”, you can use the following command to remove the password from that group:

sudo gpasswd -r mygroup

How do you delete a group in Linux?
To delete a group in Linux, you need to use the groupdel command. You need to provide the group name as well. For example, if I want to delete a group named “mygroup”, I will use the following command:

sudo groupdel mygroup

Related Articles

Rate this post
Walid Al Asad

Hello Everyone! I am Walid Al Asad. Currently, I am working at a tech company named Softeko as a Linux Content Developer Executive. I live in Dhaka, Bangladesh. I have completed my BSc. in Mechanical Engineering from Bangladesh University of Engineering and Technology (BUET). You can find me on LinkedIn, and ResearchGate. Read Full Bio

Leave a Comment