passwd-user

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

MIT 11 个版本
安装
npm install passwd-user
yarn add passwd-user
pnpm add passwd-user
bun add passwd-user
README

passwd-user

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

import {passwdUser} from 'passwd-user';

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

passwdUser(userIdentifier?)

Returns a Promise<object> with the user entry.

passwdUserSync(username?)

passwdUserSync(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.

  • username - Get the user's username (cross-platform)
  • fullname - Get the user's fullname (cross-platform)
版本列表
4.0.0 2021-11-04
3.0.0 2019-05-01
2.1.0 2016-06-01
2.0.0 2016-01-10
1.2.1 2015-07-16
1.2.0 2015-06-05
1.1.1 2015-03-09
1.1.0 2015-02-18
1.0.1 2014-11-10
1.0.0 2014-08-26
0.1.0 2014-04-28