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.
getent group app01Incorrect. It searches the group database.
getent passwd app01Correct. It obtains app01 through the configured passwd sources.
id -g app01Incorrect. 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
Account record
Identity attributes such as a user ID, home directory, and login shell.
Group membership
Primary and supplementary groups used during permission checks.
Password aging
State and time limits that control password changes and account access.