1:mod:`grp` --- The group database 2================================= 3 4.. module:: grp 5 :platform: Unix 6 :synopsis: The group database (getgrnam() and friends). 7 8-------------- 9 10This module provides access to the Unix group database. It is available on all 11Unix versions. 12 13.. include:: ../includes/wasm-notavail.rst 14 15Group database entries are reported as a tuple-like object, whose attributes 16correspond to the members of the ``group`` structure (Attribute field below, see 17``<grp.h>``): 18 19+-------+-----------+---------------------------------+ 20| Index | Attribute | Meaning | 21+=======+===========+=================================+ 22| 0 | gr_name | the name of the group | 23+-------+-----------+---------------------------------+ 24| 1 | gr_passwd | the (encrypted) group password; | 25| | | often empty | 26+-------+-----------+---------------------------------+ 27| 2 | gr_gid | the numerical group ID | 28+-------+-----------+---------------------------------+ 29| 3 | gr_mem | all the group member's user | 30| | | names | 31+-------+-----------+---------------------------------+ 32 33The gid is an integer, name and password are strings, and the member list is a 34list of strings. (Note that most users are not explicitly listed as members of 35the group they are in according to the password database. Check both databases 36to get complete membership information. Also note that a ``gr_name`` that 37starts with a ``+`` or ``-`` is likely to be a YP/NIS reference and may not be 38accessible via :func:`getgrnam` or :func:`getgrgid`.) 39 40It defines the following items: 41 42 43.. function:: getgrgid(id) 44 45 Return the group database entry for the given numeric group ID. :exc:`KeyError` 46 is raised if the entry asked for cannot be found. 47 48 .. versionchanged:: 3.10 49 :exc:`TypeError` is raised for non-integer arguments like floats or strings. 50 51.. function:: getgrnam(name) 52 53 Return the group database entry for the given group name. :exc:`KeyError` is 54 raised if the entry asked for cannot be found. 55 56 57.. function:: getgrall() 58 59 Return a list of all available group entries, in arbitrary order. 60 61 62.. seealso:: 63 64 Module :mod:`pwd` 65 An interface to the user database, similar to this. 66 67 Module :mod:`spwd` 68 An interface to the shadow password database, similar to this. 69 70