Get unlimited public & private packages + team-based management with npm Teams.Learn more »

passwd-user

3.0.0 • Public • Published

passwd-user Build Status

Get the passwd user entry from a username or user identifier (UID)

Works on macOS and Linux. See user-info if you need cross-platform support.

Install

$ npm install passwd-user

Usage

const passwdUser = require('passwd-user');
 
(async () => {
    console.log(await passwdUser('sindresorhus'));
    /*
    {
        username: 'sindresorhus',
        password: '*',
        userIdentifier: 501,
        groupIdentifier: 20,
        fullName: 'Sindre Sorhus',
        homeDirectory: '/home/sindresorhus',
        shell: '/bin/zsh'
    }
    */
 
    await passwdUser(501);
    console.log('Got entry for user 501');
 
    const user = await passwdUser();
    console.log(`Got entry for user ${user.userIdentifier}`);
})();

API

Returns an object with:

  • username
  • password
  • userIdentifier: UID
  • groupIdentifier: GID
  • fullName: Name of user
  • homeDirectory: Home directory
  • shell: Default shell

passwdUser([username | userIdentifier])

Returns a Promise<object> with the user entry.

passwdUser.sync([username | userIdentifier])

Returns an object with the user entry.

username

Type: string

The username to look up.

userIdentifier

Type: number
Default: process.getuid() (The current user)

The user identifier (UID) to look up.

Related

  • username - Get the user's username (cross-platform)
  • fullname - Get the user's fullname (cross-platform)

License

MIT © Sindre Sorhus

Install

npm i passwd-user

DownloadsWeekly Downloads

126,761

Version

3.0.0

License

MIT

Unpacked Size

9.25 kB

Total Files

5

Last publish

Collaborators

  • avatar