nerdexam
CompTIA

XK0-004 · 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 fo

The correct answer is A. Hostnamet1 set-hostname -transient tempname. The hostnamectl --transient flag sets a temporary runtime hostname that is lost on reboot, leaving the static hostname in /etc/hostname unchanged.

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

(57 responses)
  • A
    95% (54)
  • B
    2% (1)
  • D
    4% (2)

Why each option

The hostnamectl --transient flag sets a temporary runtime hostname that is lost on reboot, leaving the static hostname in /etc/hostname unchanged.

AHostnamet1 set-hostname -transient tempnameCorrect

The hostnamectl set-hostname --transient command writes only to the kernel's runtime hostname, which is held in memory and automatically discarded when the system reboots. This satisfies the requirement of a temporary change while preserving the original static hostname stored in /etc/hostname.

BHostnamect1 -H localhost tempname

The -H flag in hostnamectl targets a remote host over SSH for operations, not the local machine, and does not set any type of hostname.

CHostnamect1 set-hostname tempname

hostnamectl set-hostname without a type flag sets all three hostname types (static, pretty, and transient) simultaneously, making the change permanent across reboots via /etc/hostname.

DHostnamect1 set-hostname -static tempname

The --static flag explicitly writes the hostname persistently to /etc/hostname, which survives reboots and does not meet the requirement for a temporary, non-persistent change.

Concept tested: hostnamectl transient hostname for temporary non-persistent changes

Source: https://www.freedesktop.org/software/systemd/man/hostnamectl.html

Topics

#hostnamectl#transient hostname#system configuration#hostname management

Community Discussion

No community discussion yet for this question.

Full XK0-004 Practice