Two small settings, three big payoffs: a proper hostname makes multi-server work far less error-prone (no more running a destructive command on the wrong box), and the right timezone plus NTP sync makes logs, cron jobs and TLS certificates behave. Both take one command on Ubuntu 24.04.
Changing the hostname
hostnamectl # current state sudo hostnamectl set-hostname web01.example.com
Convention: use a fully qualified name (web01.example.com) as static hostname, and keep names short, lowercase and descriptive — web01, db01, mail. Then update /etc/hosts so sudo and local lookups stay fast:
sudo nano /etc/hosts
127.0.0.1 localhost 127.0.1.1 web01.example.com web01
The new name shows in your prompt at the next login. If a cloud image resets the hostname at reboot, set preserve_hostname: true in /etc/cloud/cloud.cfg.
Setting the timezone
timedatectl # current time, zone and NTP status timedatectl list-timezones | grep -i beirut sudo timedatectl set-timezone Asia/Beirut
Everything that timestamps — logs, cron, databases — now uses local time. Restart long-running services (cron in particular) so they pick up the change:
sudo systemctl restart cron
Keeping the clock accurate (NTP)
Ubuntu syncs time with systemd-timesyncd out of the box — verify with:
timedatectl timesync-status
If System clock synchronized says no, enable it:
sudo timedatectl set-ntp true
Accurate time is not cosmetic: TLS handshakes fail with skewed clocks, two-factor codes stop working, and database replication gets confused. If your server drifts, fix NTP before debugging anything else.
Where these settings live
The hostname is stored in /etc/hostname, the timezone is a symlink at /etc/localtime pointing into /usr/share/zoneinfo/ — hostnamectl and timedatectl simply manage these safely, so prefer them over editing files by hand.
Related Ubuntu guides
- How to Set Up Cron Jobs on Ubuntu: Automate Tasks with Crontab
- Initial Ubuntu 24.04 Server Setup Guide: Secure Your New VPS in 10 Steps
- How to Set a Static IP Address on Ubuntu Server with Netplan
- How to Manage Services on Ubuntu with systemctl: The Complete systemd Guide
Prefer to have experts handle it?
LFA IT provides fully managed Ubuntu VPS and dedicated servers — initial setup, security hardening, monitoring and 24/7 support, so you can focus on your business. Explore our hosting and server management services or open a support ticket and our engineers will take it from there.