Sub topic 3
Set hostname, locale, timezone and time sync
This chapter assumes an installed Ubuntu or RHEL-family server, an admin user with sudo, and a working SSH session. It covers the rest of the first-boot baseline: identity and clock, networking, firewall, automatic updates, systemd checks, a verification checklist, a backup, and repeatable installs.
Set the hostname, timezone and locale
Use systemd's hostnamectl, timedatectl and localectl tools:
sudo hostnamectl set-hostname web01
sudo timedatectl set-timezone UTC
sudo localectl set-locale LANG=en_US.UTF-8
timedatectl statustimedatectl status should report System clock synchronized: yes and NTP service: active. If it does not, check that systemd-timesyncd or chrony is running.
Check networking and DNS
Confirm the interface addresses and the DNS resolver in use:
ip -br addr
resolvectl statusUbuntu usually manages addresses through netplan, and RHEL-family systems use NetworkManager (nmcli). Make permanent changes through the tool your distribution uses, not by editing the runtime state.
Enable a host firewall
Allow SSH before you enable the firewall.
# Ubuntu (ufw)
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow OpenSSH
sudo ufw enable
sudo ufw status verbose
# RHEL family (firewalld)
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --reload
sudo firewall-cmd --list-allTurn on automatic security updates
# Ubuntu
sudo apt install unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades
# RHEL family
sudo dnf install dnf-automatic
sudo systemctl enable --now dnf-automatic-install.timerInspect services and logs
systemctl --failed
systemctl status ssh # use sshd on RHEL-family systems
journalctl -p err -bVerify the baseline
Run this checklist after each change:
ip -br addr
ss -tlnp
systemctl --failed
df -h
journalctl -p err -bSnapshot and automate
Take a VM or filesystem snapshot of the clean baseline before you deploy workloads. To repeat the install, use a preseed file (Debian/Ubuntu), a kickstart file (RHEL family), or an autoinstall file (Ubuntu Server), and apply the same checklist to each new machine.
Exercise
Which command confirms that the system clock is synchronized with a time source?
Show answer
timedatectl status. Look for System clock synchronized: yes and NTP service: active.