Set the static hostname of a Linux host to app01.
Choose the content to write to /etc/hostname.
Which content is appropriate?
/etc/hostname normally contains the static hostname alone on one line. IP-to-name mappings belong in a separate file such as /etc/hosts.
Detailed explanation
app01Correct. app01 is the usual one-line /etc/hostname content.
hostname=app01Incorrect. /etc/hostname normally does not use variable-assignment syntax.
127.0.0.1 app01Incorrect. An address and name mapping is /etc/hosts syntax.
nameserver app01Incorrect. nameserver is a resolver configuration directive.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' app01 | python3 -c "import sys; print(sys.stdin.read().strip())"Expected result
app01Key points
- Write the hostname on one line
- It is not an assignment
- Different role from /etc/hosts
Notes
- Environment: POSIX shell / 一時標準入力のみ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Network interface
A host attachment whose link state and addresses can be managed.
Connection profile
Saved settings used to activate a persistent network connection.
Routing table
Rules that select the next hop for each destination network.