Website hosting service by

 Back to Index

8.2 pwd -- The password database

Availability: Unix.

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>):

Index  Attribute  Meaning 
pw_name Login name
pw_passwd Optional encrypted password
pw_uid Numerical user ID
pw_gid Numerical group ID
pw_gecos User name or comment field
pw_dir User home directory
pw_shell User command interpreter

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

Note: In traditional Unix the field pw_passwd usually contains a password encrypted with a DES derived algorithm (see module crypt ). However most modern unices use a so-called shadow password system. On those unices the field pw_passwd only contains a asterisk ('*') or the letter "x" where the encrypted password is stored in a file /etc/shadow which is not world readable.

It defines the following items:

getpwuid( uid)
Return the password database entry for the given numeric user ID.
getpwnam( name)
Return the password database entry for the given user name.
getpwall( )
Return a list of all available password database entries, in arbitrary order.

See Also:

Module grp:
An interface to the group database, similar to this.



2002-2004 Webhosting Service


Disclaimer: This documentation is provided only for the benefits of our hosting customers.
For authoritative source of the documentation, please refer to


Cheap domain registrar provides cheap domain registration, buy domain name and domain transfer from $5.95/year only   Cheap domain registration : Buy domain name and enjoy comprehensive free services