Command Documentation: getpw

This turns out to duplicate getent, which is already available on Solaris and Linux. The standard getent should be used instead of getpw for all purposes.

Introduction

The getpw command is a command-line interface to the getpwnam, getpwuid, and getpwent system calls.

Description

It takes a single parameter, which may be a userid, a user number (uid), or ":". If a userid or uid is supplied, the matching entry is retrieved using getpwnam or getpwuid respectively and printed out in password file format. If the parameter is ":" then getpwent and associated calls are used to iterate through the entire set of users and the whole list is printed out.

If the userid or uid does not exist, the message "No such user!" is displayed and the program exits with status -2.

The intent of this is to replace cat /etc/passwd and similar formulations with something that should work even if there is no actual password file on the machine. The output of getpw : should be identical to the contents of the password file.

Examples

To display the password entry for user jnsmith:

getpw jnsmith

To display the password entry for the user with uid 105:

getpw 105

To display the password file:

getpw :

Bugs

The error message is displayed on stdout, not stderr where it belongs.

-- IsaacMorland - 10 Jan 2007

Topic revision: r2 - 2008-10-08 - IsaacMorland
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback