Group (database)

{{context|date=May 2013}}Group is a name service database used to store group information on Unix-like operating systems. The sources for the group database (and hence the sources for groups on a system) are configured, like other name service databases, in nsswitch.conf.{{citation needed|date=February 2024}} The database file is located at /etc/group. It contains fields representing the group name, group id, encrypted password, and users belonging to the group. These fields are stored in a structure defined in the header file .{{r|Unix}}

Seeing available groups on a Unix system

The contents of the group database (and available groups) can be seen with a variety of tools:

= C =

The header file contains the functions getgrgid and getgrname to look up a group by its ID or Name, as well as the functions setgrent, getgrent, and endgrent to iterate through all groups.{{cite book |last1=Stevens |first1=W. Richard |last2=Rago |first2=Stephen A. |title=Advanced programming in the UNIX environment |date=2013 |publisher=Addison-Wesley |location=Upper Saddle River (NJ) |isbn=978-0-321-63773-4 |pages=182–183 |edition=third}}

= Command line =

The getent command can be used to fetch group information.{{citation needed|date=February 2024}}

== Fetching a list of all available groups ==

getent group

== Fetching a specific group ==

For a specific group called 'users':

getent group users

= Python =

  • [https://docs.python.org/lib/module-grp.html grp - The Group Database] — a Python module

References

{{Reflist}}

{{DEFAULTSORT:Group (Database)}}

Category:Unix authentication-related software

{{unix-stub}}