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:
This will show you all the groups currently logged in user belongs to.
Similarly, if you want to check the groups for a specific user, the command should look like. Replace username with the actual user.
Suppose, you want to check which groups a user ‘karim’ belongs to, execute the following command on terminal.
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.
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
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.
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
Thank you for reading. I hope this tutorial has been useful to you.