pwd
The pwd module provides access to the UNIX password database.
getpwuid(uid)
Returns the password database entry for a numeric user ID, uid. Returns a password structure with the following attributes:
pw_name— The login name
pw_passwd— The encrypted password (optional)
pw_uid— The numerical user ID
pw_gid— The numerical group ID
pw_gecos— The username or comment field
pw_dir— The user home directory
pw_shell— The user shell
For backward compatibility, the returned object also behaves like a 7-tuple (pw_name, pw_passwd, pw_uid, pw_gid, pw_gecos, pw_dir, pw_shell). KeyError is raised if the entry cannot be found.
getpwnam(name)
Returns the password database entry for a username.
getpwall()
Returns a list of all available password database entries. ...
Get Python: Essential Reference, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.