CertGrid CertGrid
Hands-on Lab·Linux Foundation Certified System Administrator

Hostnames, and the three of them

A hostname looks like the simplest thing on a Linux system and is not: there are three of them, two files involved, and a difference between changing it now and changing it permanently. This guide changes one and puts it back.

Networking Guide 25 of 38 Beginner

hostnamectl is systemd and behaves identically on both families. The 127.0.1.1 convention is Debian and Ubuntu; RHEL does it differently, and the page shows both.

Ubuntu leads every step because it is what LFCS is most likely to hand you; RHEL follows so the difference is visible rather than described.
Server NameIP AddressOSRolesCPURAMHDD
LFCS-A01192.168.0.70Ubuntu 26.04 LTSPrimary host - most guides run only here2 Core4 GB50 GB
LFCS-C01192.168.0.72AlmaLinux 10.2The other distribution - dnf, firewalld and NetworkManager2 Core4 GB50 GB

This guide includes

Use this because a hostname is not one thing but three. This matters because hostname -f depends on a line in /etc/hosts rather than on what the machine calls itself.

Before you start

  1. What this machine calls itself

  2. The line that makes -f work

  3. Changing it, and putting it back

Official sources