Identify the home-directory field in a record using /etc/passwd format.
app01:x:2100:2100:Application User:/srv/apps/app01:/bin/bashWhich field number is the home directory?
/etc/passwd fields are name, password placeholder, UID, GID, GECOS, home, and shell. Home is field 6.
Detailed explanation
Incorrect. Field 3 is the numeric UID.
Incorrect. Field 3 is the numeric UID.
Incorrect. Field 4 is the primary GID.
Incorrect. Field 4 is the primary GID.
Incorrect. Field 5 is the GECOS/comment field.
Incorrect. Field 5 is the GECOS/comment field.
Correct. Field 6 contains the home path.
Correct. Field 6 contains the home path.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' 'app01:x:2100:2100:Application User:/srv/apps/app01:/bin/bash' | cut -d: -f6Expected result
/srv/apps/app01Key points
- Fields use colons
- Home is field 6
- Shell is field 7
Notes
- Environment: POSIX cut / 一時標準入力のみ
- 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.