How to find out what group a given user has? How to find out what group a given user has? unix unix

How to find out what group a given user has?


This one shows the user's uid as well as all the groups (with their gids) they belong to

id userid


On Linux/OS X/Unix to display the groups to which you (or the optionally specified user) belong, use:

id -Gn [user]

which is equivalent to groups [user] utility which has been obsoleted on Unix.

On OS X/Unix, the command id -p [user] is suggested for normal interactive.

Explanation on the parameters:

-G, --groups - print all group IDs

-n, --name - print a name instead of a number, for -ugG

-p - Make the output human-readable.