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
- PlatformsUbuntu 26.04 LTS + AlmaLinux 10.2
- LVM2.03.31 (Ubuntu) / 2.03.36 (AlmaLinux)
- nftables1.1.6 (Ubuntu) / 1.1.5 (AlmaLinux)
- TimeAbout 10 min
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.
- Firewallufw 0.36.2 enabled but reporting inactive / firewalld active
- Network confignetplan + systemd-networkd / NetworkManager 1.56.0
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| LFCS-A01 | 192.168.0.70 | Ubuntu 26.04 LTS | Primary host - most guides run only here | 2 Core | 4 GB | 50 GB |
| LFCS-C01 | 192.168.0.72 | AlmaLinux 10.2 | The other distribution - dnf, firewalld and NetworkManager | 2 Core | 4 GB | 50 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.
- asking three commands that are not asking the same question
- finding the line that makes
-fwork - changing the hostname everywhere at once, and putting it back
Before you start
- guide 25 - why
/etc/hostsmatters here.
-
What this machine calls itself
-
The line that makes -f work
-
Changing it, and putting it back