Group (database)

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

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] 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 <grp.h>.[1]

Seeing available groups on a Unix system

[edit | edit source]

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

The <grp.h> 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.[1]

Command line

[edit | edit source]

The getent command can be used to fetch group information.[citation needed]

Fetching a list of all available groups

[edit | edit source]
getent group

Fetching a specific group

[edit | edit source]

For a specific group called 'users':

getent group users

Python

[edit | edit source]

References

[edit | edit source]
  1. ^ a b Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).