In Linux, how do I get a list of all the groups a particular user is a member of?


If you are the user:


If he is someone else:

groups hisname
| improve this answer | |

Use the groups command, i.e.

groups username
| improve this answer | |

The id command will list group memberships by both name and id number.

| improve this answer | |

You could simply pilfer through the /etc/group file. It has a simple format: groupname: username, username2, username3, with one group per line.

Or, grep through it.

grep '[:,]username' /etc/group
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.