The functions and data structures for accessing the system user database are declared in the header file pwd.h.
The passwd data structure is used to hold information about
entries in the system user data base. It has at least the following members:
char *pw_nameThe user’s login name.
char *pw_passwdHistorically, this field would hold the one-way hash of the user’s passphrase. Nowadays, it will almost always be the single character ‘x’, indicating that the hash is in the shadow database.
uid_t pw_uidThe user ID number.
gid_t pw_gidThe user’s default group ID number.
char *pw_gecosA string typically containing the user’s real name, and possibly other information such as a phone number.
char *pw_dirThe user’s home directory, or initial working directory. This might be a null pointer, in which case the interpretation is system-dependent.
char *pw_shellThe user’s default shell, or the initial program run when the user logs in. This might be a null pointer, indicating that the system default should be used.