XK0-005 · Question #352
A Linux administrator is testing a configuration script and wants to change the hostname of a workstation temporarily, but it must return to its assigned workstation name after reboot. Which of the…
The correct answer is A. Hostnamet1 set-hostname -transient tempname. This question asks for the hostnamectl command option to set a hostname temporarily without persisting across reboots.
Question
A Linux administrator is testing a configuration script and wants to change the hostname of a workstation temporarily, but it must return to its assigned workstation name after reboot. Which of the following is the BEST command for the administrator to use?
Options
- AHostnamet1 set-hostname -transient tempname
- BHostnamect1 -H localhost tempname
- CHostnamect1 set-hostname tempname
- DHostnamect1 set-hostname -static tempname
How the community answered
(44 responses)- A89% (39)
- B2% (1)
- C7% (3)
- D2% (1)
Why each option
This question asks for the hostnamectl command option to set a hostname temporarily without persisting across reboots.
The `hostnamectl set-hostname -transient tempname` command correctly sets the system's transient hostname. The `-transient` flag ensures this change is active only until the next reboot, after which the system will revert to its static or configured hostname, fulfilling the requirement for a temporary change.
`hostnamectl -H localhost tempname` is syntactically incorrect and does not specify a temporary hostname change.
`hostnamectl set-hostname tempname` without any flags would set both the static and transient hostnames, making the change persistent across reboots, which is not desired.
`hostnamectl set-hostname -static tempname` explicitly sets the static hostname, making the change permanent and persisting across reboots, which contradicts the requirement for a temporary change.
Concept tested: Managing Linux hostnames temporarily
Source: https://man7.org/linux/man-pages/man1/hostnamectl.1.html
Topics
Community Discussion
No community discussion yet for this question.