O'Reilly logo

Python: Essential Reference, Third Edition by David Beazley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

grp

The grp module provides access to the UNIX group database.

getgrgid(gid)

Returns the group database entry for a group ID, gid. The returned object is a group structure with the following attributes:

  • gr_name—The group name

  • gr_passwd—The group password (if any)

  • gr_gid—The integer group ID

  • gr_mem—A list of usernames in the group

The returned object also behaves like a 4-tuple (gr_name, gr_passwd, gr_gid, gr_mem). Raises KeyError if the group doesn’t exist.

getgrnam(name)

Same as getgrgid(), but looks up a group by name.

getgrall()

Returns all available group entries as a list of tuples as returned by getgrgid().

See Also

pwd (p. 332)

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required