How to see which groups a user is member of in Debian 10

This small tutorial is going to teach you how to check which groups user account belongs to in Debian 10 and how to add or remove users from groups. However, the steps in this tutorial will work for most other Linux distributions too.

How to see which groups a Linux user belongs to

Open up the terminal and run the following command:

groups

This will show you all the groups currently logged in user belongs to.

Linux groups command

Similarly, if you want to check the groups for a specific user, the command should look like. Replace username with the actual user.

groups <username>

Suppose, you want to check which groups a user 'karim' belongs to, execute the following command on terminal.

groups karim

Check which groups a user is member of

How to add a user to a specific group

You can add a user to a specific group with the help of usermod command. The syntax of complete command should look like as follows.

usermod -G <groupname> <username>

Suppose you want to add a user karim to the sudo group, run the following command in the terminal with root privileges.

usermod -G sudo karim

Add user to group on Linux

Similarly, if you want to remove a user from a specific group, execute the following command with root privileges. Replace the actual group and user name.

gpasswd -d <“username”> <group>

How to remove a user from a specific group

Suppose you want to remove the user karim from a sudo group, the command should look like.

gpasswd -d karim sudo

Remove user from group

Thank you for reading. I hope this tutorial has been useful to you.