Courseiva
System Management →mediumMultiple Choice

XK0-006 System Management Practice Question

A system administrator needs to change the hostname of a Linux server running systemd to 'webserver01'. Which command will accomplish this?

⚠ Common exam trap

The trap here is using the hostname command, which only changes the hostname temporarily, rather than hostnamectl for a persistent change.

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 is the correct tool to set the hostname persistently. The set-hostname subcommand updates the static hostname and writes it to /etc/hostname, ensuring it survives reboots. Other methods like the hostname command or sysctl are temporary or incorrect for this purpose.

Answer analysis

Option-by-option breakdown

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

  • ✓

    hostnamectl set-hostname webserver01

    Why this is correct

    hostnamectl is the systemd utility for managing hostnames. The set-hostname subcommand sets the static hostname to the specified value. This change is persistent across reboots and updates /etc/hostname. It is the recommended method on modern Linux distributions using systemd.

  • ✗

    hostname webserver01

    Why it's wrong here

    The hostname command with an argument changes the hostname temporarily for the current session only. It does not persist after a reboot. To make a permanent change, additional steps like editing /etc/hostname or using hostnamectl are required. This command is insufficient for a persistent change.

  • ✗

    sysctl kernel.hostname=webserver01

    Why it's wrong here

    sysctl is used to modify kernel parameters at runtime. While kernel.hostname exists, setting it via sysctl changes the hostname only until reboot and is not the standard method. It also does not update configuration files. This is not a persistent solution and is not recommended for hostname changes.

  • ✗

    echo webserver01 > /etc/hosts

    Why it's wrong here

    The /etc/hosts file maps IP addresses to hostnames; it does not set the system's hostname. Writing a hostname to it does not change the system's identity. This command would corrupt the hosts file by removing existing entries. It does not accomplish the task of changing the hostname.

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.