Welcome, guest | Sign In | My Account | Store | Cart

The Python stdlib pwd module provides an easy way to get the primary group ID, but no way to get additional group IDs. This is a simple function that returns the additional group IDs for a given username.

Python, 2 lines
def get_additional_group_ids(username):
    return [g.gr_gid for g in grp.getgrall() if username in g.gr_mem]