How to Check the User Group(s) an Ubuntu User Belongs To linux shell ubuntu

As an Ubuntu system administrator, you can create and manage groups for the user accounts on your system. This way you can assign administrative & configurations rights, files & folder access permissions to an entire group rather than a single user at a time. Sometimes we need to know which user group a user belongs to in order to verify or perform group management operations or for assigning/de-assigning user rights. This Group Management on Ubuntu 20.04 only through the command line. In this article, we will describe the simple commands used to perform this effortless check.

Open the Ubuntu Terminal through Ctrl Alt T or through the Dash.

Enter the following command in order to see which group the current user belongs to:

$ groups

This command lists all the groups that you belong to.

Enter the following command to check which group a certain user belongs to:

$ groups [username]

You can also use the following command to list the group members along with their GIDs.

$ id [username]

Here is an example for the ‘guest’ user:

<img alt="Groups the guest user belongs to" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-186.png624e985f5257f.jpg" data-ez ezimgfmt="rs rscb10 src ng ngcb10 srcset" height="76" loading="lazy" src="data:image/svg xml,” width=”591″>

The gid output represents the primary group assigned to a user.

Enter the exit command in order to close the terminal window in case you do not want to work further.

Through this simple procedure, you can perform a simple check of a user account’s group information.