On a host whose accounts come partly from local files and partly from a directory service, `grep alice /etc/passwd` returns nothing even though `id alice` works. Which command shows alice's account entry the way the system itself resolves it?

LPIC-1 Exam 102-500, objective 107. Administrative tasks medium

Draft — not checked yet. This question was written from the published exam objectives and cites the clause it comes from, but nobody has yet read it against that clause and signed for it.

It is kept out of search results and out of mock exams until they have. Read the source below before you take the answer as settled.

The options

Correct getent passwd alice

Correct. getent queries the Name Service Switch, so it walks whatever sources /etc/nsswitch.conf lists for the passwd database — files, then for example ldap or sss — and prints the resulting entry in passwd format.

Not correct cat /etc/shadow | grep alice

Wrong. /etc/shadow only ever holds locally defined accounts, and only their password and aging data. A directory-supplied account is not in it.

Not correct passwd -S alice

Wrong for this purpose. passwd -S prints the password status of an account: whether it is usable, locked or empty, plus the aging numbers. It is a status report, not the account entry.

Not correct groups alice

Wrong. groups lists the groups alice belongs to. It tells you nothing about her UID, home directory or shell.

Why

getent is the general front end to NSS databases: `getent passwd`, `getent group`, `getent shadow`, `getent hosts`. Because it goes through NSS it sees exactly the same data the login process sees, which is why it is the correct diagnostic on any system where accounts do not live purely in /etc/passwd. With no key it dumps the whole database.

Where this comes from

Cited
LPI exam objective 107.1
What it says
Query user and group databases with getent.

Practise this

Reading one question is not practice. The trainer will draw a set from objective 107 and space the ones you get wrong.

Practise LPIC-1 Exam 102-500