To display the groups a Linux user belongs to, you can use the groups or id commands.
Using the groups command:
To list the groups for the current user, simply type:
Code
groups
To list the groups for a specific user, replace [username] with the actual username:
Code
groups [username]
Using the id command:
The id command provides more detailed information, including the user ID (UID), primary group ID (GID), and all supplementary group IDs and names.
To display information for the current user, type:
Code
id
To display information for a specific user, replace [username] with the actual username:
Code
id [username]
To specifically display only the group names in a human-readable format, use the -Gn options:
Code
id -Gn [username]