Courseiva
Essential Tools →hardMultiple Select

EX200 Essential Tools Practice Question

Which TWO methods can be used to permanently set the system's hostname to 'server01.example.com'?

⚠ Common exam trap

Candidates often confuse setting the hostname with hostname resolution, picking option B (editing `/etc/hosts`) because they think it permanently sets the hostname, when it only affects local DNS-like lookups and does not change the system's actual hostname.

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 server01.example.com

`hostnamectl set-hostname server01.example.com` is the systemd-based command that permanently sets the hostname by writing to `/etc/hostname` and applying the change immediately via the `hostnamed` service. This is the recommended method on RHEL 8/9 systems, as it updates both the transient and static hostnames, ensuring persistence across reboots.

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 server01.example.com

    Why this is correct

    hostnamectl set-hostname server01.example.com writes the given name to /etc/hostname as the static hostname and also signals systemd-hostnamed to apply it immediately to the running kernel, so the change takes effect right away and remains after reboot. It is the systemd-native command and the official tool on RHEL systems; unlike writing /etc/hostname directly, it also updates the transient hostname by default and can set other metadata such as the pretty hostname. This is the recommended and most robust method.

  • ✗

    echo '127.0.1.1 server01.example.com' >> /etc/hosts

    Why it's wrong here

    Appending '127.0.1.1 server01.example.com' to /etc/hosts merely adds a static name-resolution mapping that tells the resolver that the hostname server01.example.com belongs to the loopback IP address 127.0.1.1. It does not alter the kernel's actual hostname (stored in /proc/sys/kernel/hostname) and does not modify the persistent hostname configuration in /etc/hostname. Many distributions put a hostname entry in /etc/hosts for convenience, but the system hostname itself is not defined there.

  • ✓

    echo 'server01.example.com' > /etc/hostname

    Why this is correct

    Writing 'server01.example.com' to /etc/hostname is persistent because systemd reads this file at boot and applies its contents as the static hostname. However, this command does not change the running hostname instantly; the new value takes effect only after a reboot or after manually running a command like systemctl restart systemd-hostnamed. This method is functionally equivalent to the persistence aspect of hostnamectl set-hostname, but lacks the immediate runtime update that hostnamectl performs.

  • ✗

    hostname server01.example.com

    Why it's wrong here

    The hostname command sets the kernel's transient hostname directly, but the change exists only in memory and is not written to any configuration file. It is specifically used for temporary, runtime adjustments—for example, during a network session—and on the next reboot the hostname reverts to whatever is stored in /etc/hostname. Because it does not touch /etc/hostname or any persistent setting, it is not a valid way to permanently set the system hostname in RHEL.

  • ✗

    echo 'HOSTNAME=server01.example.com' >> /etc/sysconfig/network

    Why it's wrong here

    The line HOSTNAME=server01.example.com appended to /etc/sysconfig/network reflects the legacy SysVinit hostname configuration that was used on older RHEL versions such as 5 and 6. On modern RHEL with systemd, this file is not consulted for hostname setup; systemd relies on /etc/hostname exclusively, so adding the variable here has no effect. Furthermore, appending to the file without replacing its existing content—while not the core problem—also illustrates this is an unsupported, outdated approach.

About these practice questions

This EX200 question is part of Courseiva's 427-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 by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This EX200 practice question is part of Courseiva's free Red Hat 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 EX200 exam.