Look up users and groups with getent
Query the real account database through NSS — catches LDAP and Active Directory users that grepping /etc/passwd misses.
Run `getent passwd alice` to resolve a user and `getent group sudo` to list a group's members, wherever the accounts live.
01Command
Command
$ getent passwd alice && getent group sudo02What it does
grepping /etc/passwd only sees local files, but NSS may source accounts from LDAP, SSSD, or Active Directory — getent goes through the same lookup chain login does, so it answers whether this user actually exists to the system. Exit status is the trick: `getent passwd alice >/dev/null && echo exists` is the canonical existence check in scripts. To enumerate every account the system can see (including domain users), run `getent passwd` with no argument.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- getent(1) — get entries from Name Service Switch librariesEvidence: Documents getent querying NSS databases such as passwd and group, including entries from remote sources.
Last verified: 2026-09-17 · Category: Security & Privacy