LFCS · Question #350
When logged in to a workstation which retrieves most of its user information from NIS, which command can be used to list ALL the users?
The correct answer is D. getent passwd. The getent passwd command is the appropriate utility on Unix-like systems to comprehensively list all users by querying various name service databases, including NIS.
Question
Options
- Acat /etc/passwd
- Bshow users
- Cypusers list
- Dgetent passwd
- Ecat /var/lib/nis/passwd
How the community answered
(30 responses)- A7% (2)
- B3% (1)
- D87% (26)
- E3% (1)
Why each option
The `getent passwd` command is the appropriate utility on Unix-like systems to comprehensively list all users by querying various name service databases, including NIS.
`cat /etc/passwd` will only display users defined in the local password file and will not show users sourced from NIS.
`show users` is not a standard Unix command for listing system users, especially from NIS.
`ypusers list` is not a valid or standard NIS command for listing users; while `ypcat passwd` could list NIS password map entries, `getent passwd` is the more generalized solution.
The `getent passwd` command queries the Name Service Switch (NSS) configuration, which is designed to retrieve user information from all configured sources, including local files (`/etc/passwd`), NIS, or LDAP, thereby providing a complete list of all accessible users.
`cat /var/lib/nis/passwd` would attempt to read raw NIS map files, which are server-side and not directly parsed by clients to list users comprehensively, and this path is not universally standard for client user enumeration.
Concept tested: Unix command for NIS user enumeration
Source: https://man7.org/linux/man-pages/man1/getent.1.html
Topics
Community Discussion
No community discussion yet for this question.