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.

LinuxgetentnssusersMedium risk
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 sudo

02What 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

RiskMedium risk
Requirementsglibc (getent is present on virtually every distro)

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-09-17 · Category: Security & Privacy