Look up alice using the configured NSS sources, including possible LDAP sources rather than only local files.
Which command is appropriate?
getent DATABASE KEY queries the configured Name Service Switch sources, such as passwd or group.
Detailed explanation
cat /etc/passwd | grep '^alice:'Incorrect. grep of /etc/passwd searches only the local file.
Incorrect. grep of /etc/passwd searches only the local file.
passwd aliceIncorrect. passwd starts a password-change operation.
Incorrect. passwd starts a password-change operation.
getent group aliceIncorrect. It queries the group database, not the passwd database.
Incorrect. It queries the group database, not the passwd database.
getent passwd aliceCorrect. getent passwd alice follows NSS configuration to find alice.
Correct. getent passwd alice follows NSS configuration to find alice.
Try it yourself
An example you can run in a temporary verification environment.
getent passwd "$(id -un)" | cut -d: -f1,3,6,7Expected result
現在ユーザーの名前、UID、ホーム、shellKey points
- getent uses NSS
- passwd database
- Query by key
Notes
- Environment: glibc getent / 読取のみ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.