Linux Blog

What groups am I in?

Filed under: Quick Linux Tutorials — TheLinuxBlog.com at 10:45 am on Tuesday, April 21, 2009

@nongeekboy on Twitter tweeted? about a blog post: Simple Script To List Groups in passwd File. I read it and have done something similar before so I figured I’d blog it here so I won’t have to write it again. Anyway, along with the point of this post, since this is suppose to be quick.

A question that is often asked is “What groups am I in?”

The easiest way to find out is to type the command: groups
This will give you a list of the groups you are in separated by a space. There are some other fancy ways of getting the groups but they rely on the `id` command. Running groups with no user name, its the same as running id -Gn.

Here are some other variations that you can try if you need to script the output:

1
2
3
4
5
6
7
8
9
groups
id
id -G
id -g
id -n
id -nG [user]
and the obvious:
id --help
info id