Toggle navigation

pwd --- The password database

pwd --- The password database[UNKNOWN NODE transition]

This module provides access to the Unix user account and password database. It is available on all Unix versions.

Password database entries are reported as a tuple-like object, whose attributes correspond to the members of the passwd structure (Attribute field below, see <pwd.h>):

IndexAttributeMeaning
0pw_nameLogin name
1pw_passwdOptional encrypted password
2pw_uidNumerical user ID
3pw_gidNumerical group ID
4pw_gecosUser name or comment field
5pw_dirUser home directory
6pw_shellUser command interpreter

The uid and gid items are integers, all others are strings. KeyError is raised if the entry asked for cannot be found.

It defines the following items:

pwd.getpwuid(uid)

Return the password database entry for the given numeric user ID.

pwd.getpwnam(name)

Return the password database entry for the given user name.

pwd.getpwall()

Return a list of all available password database entries, in arbitrary order.