Map 192.0.2.20 to canonical name app.example.test and alias app in /etc/hosts.
Which line is appropriate?
A hosts record uses address, canonical hostname, and optional aliases separated by spaces.
Detailed explanation
app.example.test app 192.0.2.20Incorrect. The address must come first.
Incorrect. The address must come first.
app.example.test 192.0.2.20 appIncorrect. The address and name positions are reversed.
Incorrect. The address and name positions are reversed.
192.0.2.20 app.example.test appCorrect. It uses address, canonical name, and alias order.
Correct. It uses address, canonical name, and alias order.
192.0.2.20 app=app.example.testIncorrect. Hosts aliases are not assignment expressions.
Incorrect. Hosts aliases are not assignment expressions.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' '192.0.2.20 app.example.test app' | awk '{ print $1, $2, $3 }'Expected result
192.0.2.20 app.example.test appKey points
- Address first
- Canonical name
- Aliases follow
Notes
- Environment: POSIX awkによるrecord field確認
- 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.