# passwd-user

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

Latest version **4.0.0** (published 2021-11-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install passwd-user
pnpm add passwd-user
yarn add passwd-user
bun add passwd-user
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2021-11-04 |
| First published | 2014-04-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | ^12.20.0 \|\| ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 1 |
| Unpacked size | 8.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 31 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | passwd, linux, macos, osx, uid, gid, pw, getpwuid, posix, unix, shell, home, dir, username, user, etc, password, passwords, identifier |

## Links

- npm: https://www.npmjs.com/package/passwd-user
- Repository: https://github.com/sindresorhus/passwd-user
- Homepage: https://github.com/sindresorhus/passwd-user#readme
- Issues: https://github.com/sindresorhus/passwd-user/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/passwd-user

## Dependencies (1)

- [execa](https://npm.io/package/execa.md) ^5.1.1

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 4.0.0 (latest) — 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

## README

# passwd-user

> Get the [passwd](https://en.wikipedia.org/wiki/Passwd) user entry from a username or [user identifier (UID)](https://en.wikipedia.org/wiki/User_identifier_(Unix))

Works on macOS and Linux. See [`user-info`](https://github.com/sindresorhus/user-info) if you need cross-platform support.

## Install

```sh
npm install passwd-user
```

## Usage

```js
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](https://en.wikipedia.org/wiki/User_identifier)
- `groupIdentifier`: [GID](https://en.wikipedia.org/wiki/Group_identifier)
- `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()`](https://nodejs.org/api/process.html#process_process_getuid) (The current user)

The [user identifier (UID)](https://en.wikipedia.org/wiki/User_identifier) to look up.

## Related

- [username](https://github.com/sindresorhus/username) - Get the user's username *(cross-platform)*
- [fullname](https://github.com/sindresorhus/fullname) - Get the user's fullname *(cross-platform)*

---
_Source: https://npm.io/package/passwd-user · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
