86

I'm trying to find my current logged in group without wanting to use newgrp to switch.

Ian F
  • 2,101
  • 2
  • 10
  • 10

2 Answers2

114

I figured I can use the following.

id -g

To get all the groups I belong

id -G

And to get the actual names, instead of the ids, just pass the flag -n.

id -Gn

This last command will yield the same result as executing

groups
yivi
  • 105
  • 4
Ian F
  • 2,101
  • 2
  • 10
  • 10
31

To get group name needed one more flag: id -g -n

Volo
  • 421
  • 4
  • 8