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

Machine-checked — no person has signed for it. This question was read against the source cited below by an automated pass, which found no contradiction. That is a weaker claim than it sounds: the same kind of process wrote the question, so it can confirm its own mistake.

Treat it as a good draft rather than as settled fact, and read the source below before you rely on it. It is not used in mock exams here — only questions a person has signed for are.

How these questions are written — where each question comes from, what the verification ledger records, and what happens when one is found wrong.

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 short set from objective 107 and space the ones you get wrong.

Practise LPIC-1 Exam 102-500

More questions on this objective

All questions on Administrative tasks

Practise LPIC-1 Exam 102-500