Courseiva
System Management →easyMultiple Choice

XK0-006 System Management Practice Question

A Linux administrator needs to change the hostname of a system to 'webserver01' permanently. The system uses systemd. Which command should the administrator use?

⚠ Common exam trap

The trap here is assuming that editing /etc/hosts or using the hostname command alone will persist the change, but only hostnamectl writes to the appropriate configuration.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

hostnamectl set-hostname webserver01

On systemd-based systems, hostnamectl set-hostname is the correct command to permanently change the hostname. It updates the static hostname in /etc/hostname and applies the change immediately. Other methods either change only the runtime hostname or modify unrelated configuration files.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    hostname webserver01

    Why it's wrong here

    The hostname command changes the hostname immediately but does not make it persistent across reboots. After a restart, the system reverts to the previous hostname stored in configuration files. This command is useful for temporary changes but does not satisfy the requirement for a permanent change.

  • ✗

    sysctl kernel.hostname=webserver01

    Why it's wrong here

    sysctl kernel.hostname sets the hostname at runtime, but it is not persistent and may not be writable on all systems. It also does not update /etc/hostname, so the change is lost on reboot. This method is not the standard way to change the hostname on systemd systems.

  • ✓

    hostnamectl set-hostname webserver01

    Why this is correct

    hostnamectl set-hostname updates the system hostname and writes it to /etc/hostname, ensuring persistence across reboots. It is the recommended method on systemd-based distributions. This command also updates the transient hostname immediately, so the change takes effect without a reboot.

  • ✗

    echo webserver01 > /etc/hosts

    Why it's wrong here

    Writing to /etc/hosts does not change the system hostname; it only modifies local hostname resolution. The /etc/hosts file maps IP addresses to hostnames for name resolution, but the kernel hostname remains unchanged. This would not affect the output of hostname or the system's identity on the network.

About these practice questions

This XK0-006 question is part of Courseiva's 781-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official CompTIA exam blueprint

This XK0-006 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the XK0-006 exam.