Store static hostname node1 for loading during boot on a standard systemd system.
Which file is appropriate?
/etc/hostname normally stores the static hostname; /etc/hosts provides address-to-name mappings instead.
Detailed explanation
/etc/hostsIncorrect. /etc/hosts maps addresses to names.
Incorrect. /etc/hosts maps addresses to names.
/etc/hostnameCorrect. /etc/hostname stores the static hostname.
Correct. /etc/hostname stores the static hostname.
/etc/resolv.confIncorrect. /etc/resolv.conf configures DNS resolution.
Incorrect. /etc/resolv.conf configures DNS resolution.
/etc/nsswitch.confIncorrect. /etc/nsswitch.conf controls lookup order.
Incorrect. /etc/nsswitch.conf controls lookup order.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' '/etc/hostname -> static hostname'Expected result
/etc/hostname -> static hostnameKey points
- /etc/hostname
- One-line static name
- Separate from hosts
Notes
- Environment: file役割対応表の表示のみ
- 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.