4

I can use the following command to get the effective group ID of a process:

ps -o pid,egid

But how can I get the supplementary groups IDs of a process?

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
user7681202
  • 1,273
  • 2
  • 14
  • 25
  • 1
    Possible duplicate of [GID, current, primary, supplementary, effective and real group IDs?](https://unix.stackexchange.com/questions/18198/gid-current-primary-supplementary-effective-and-real-group-ids) – Ipor Sircer Dec 08 '17 at 23:51
  • 1
    Ipor, that’s an informative link, but I don’t think it answers the question posed here: how to *get* those group ids. – Jeff Schaller Dec 09 '17 at 00:50

2 Answers2

6

On linux these are available for a process in /proc/pid/status:

-bash-4.2$ grep \^Groups /proc/$$/status
Groups: 6 9 11 18 100 1000
-bash-4.2$ 

it may be useful to read through the proc(5) manual for what is stored in the various /proc files.

thrig
  • 34,333
  • 3
  • 63
  • 84
4

The man page has these format specifiers:

supgid      SUPGID    group ids of supplementary groups, if any.  See getgroups(2).     
supgrp      SUPGRP    group names of supplementary groups, if any.  See getgroups(2).

So, ps -o supgid etc. Though if you use supgrp with some other columns, the default width might not fit all groups if there are many, so you may want to widen it, e.g.
ps -o pid,supgrp:100,args

ilkkachu
  • 133,243
  • 15
  • 236
  • 397