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.
Correct. app01 is the usual one-line /etc/hostname content.
hostname=app01Incorrect. /etc/hostname normally does not use variable-assignment syntax.
Incorrect. /etc/hostname normally does not use variable-assignment syntax.
127.0.0.1 app01Incorrect. An address and name mapping is /etc/hosts syntax.
Incorrect. An address and name mapping is /etc/hosts syntax.
nameserver app01Incorrect. nameserver is a resolver configuration directive.
Incorrect. 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
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.