Misplaced Pages

Group (database)

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
This article provides insufficient context for those unfamiliar with the subject. Please help improve the article by providing more context for the reader. (May 2013) (Learn how and when to remove this message)

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. 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>.

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 <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.

Command line

The getent command can be used to fetch group information.

Fetching a list of all available groups

getent group

Fetching a specific group

For a specific group called 'users':

getent group users

Python

References

  1. ^ Stevens, W. Richard; Rago, Stephen A. (2013). Advanced programming in the UNIX environment (third ed.). Upper Saddle River (NJ): Addison-Wesley. pp. 182–183. ISBN 978-0-321-63773-4.


Stub icon

This Unix-related article is a stub. You can help Misplaced Pages by expanding it.

Categories: