Retrieve passwd information for app01 according to the current NSS configuration, not just local files.
Which command is appropriate?
getent passwd USER queries the passwd database through nsswitch.conf, using local or external sources as configured.
Detailed explanation
grep '^app01:' /etc/passwdIncorrect. grep reads only /etc/passwd.
Incorrect. grep reads only /etc/passwd.
getent group app01Incorrect. It searches the group database.
Incorrect. It searches the group database.
getent passwd app01Correct. It obtains app01 through the configured passwd sources.
Correct. It obtains app01 through the configured passwd sources.
id -g app01Incorrect. id -g displays only the primary GID.
Incorrect. id -g displays only the primary GID.
Try it yourself
An example you can run in a temporary verification environment.
getent passwd $(id -un)Expected result
現在ユーザーのpasswd形式のレコードKey points
- getent uses NSS
- Select the passwd database
- grep is local-file only
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.