Categories: DebianLinuxShell

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.

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

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

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

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

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Recent Posts

How to Install Magento 2 on AlmaLinux

Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…

1 year ago

How to Install ISPConfig Hosting Control Panel with Apache Web Server on Ubuntu 24.04

ISPConfig is an open-source control panel that allows users to manage multiple servers from a…

1 year ago

How to Test your Email Server (SMTP) Using the Telnet Command

As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…

1 year ago

Managing Network Interfaces and Settings on Ubuntu 24.04 with nmcli

Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…

2 years ago

Using Restic Backup on Ubuntu 24.04

Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…

2 years ago

Installing phpMyAdmin on Rocky Linux 9 and Securing it with Let’s Encrypt SSL

phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…

2 years ago