nerdexam
CompTIA

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.

System Management

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)
  • A
    89% (39)
  • B
    2% (1)
  • C
    7% (3)
  • D
    2% (1)

Why each option

This question asks for the hostnamectl command option to set a hostname temporarily without persisting across reboots.

AHostnamet1 set-hostname -transient tempnameCorrect

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.

BHostnamect1 -H localhost tempname

`hostnamectl -H localhost tempname` is syntactically incorrect and does not specify a temporary hostname change.

CHostnamect1 set-hostname tempname

`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.

DHostnamect1 set-hostname -static tempname

`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

#Linux administration#Hostname management#hostnamectl command#System configuration

Community Discussion

No community discussion yet for this question.

Full XK0-005 Practice