102-500 · Question #114
Which of the following getent invocations lists all existing users?
The correct answer is C. getent passwd. getent passwd queries the passwd database, which is the standard Unix/Linux database containing all user account entries - each line includes username, UID, GID, home directory, and shell. This is the authoritative way to list all users because it respects NSS (Name Service…
Question
Options
- Agetent homes
- Bgetent uids
- Cgetent passwd
- Dgetent users
- Egetent logins
How the community answered
(26 responses)- A4% (1)
- B8% (2)
- C73% (19)
- D15% (4)
Explanation
getent passwd queries the passwd database, which is the standard Unix/Linux database containing all user account entries - each line includes username, UID, GID, home directory, and shell. This is the authoritative way to list all users because it respects NSS (Name Service Switch), pulling from /etc/passwd and any configured sources like LDAP or NIS.
The distractors fail because getent only accepts valid NSS database names: homes, uids, users, and logins are not valid databases recognized by getent, so those invocations would return an error or empty output. The valid databases include passwd, group, hosts, services, shadow, and a handful of others - nothing resembling the made-up names in A, B, D, and E.
Memory tip: Think "passwd = people." Just as /etc/passwd has always stored user accounts (historically with passwords, now just metadata), getent passwd is the NSS-aware equivalent - same name, same data, broader sources.
Topics
Community Discussion
No community discussion yet for this question.