Introduction
Correct date and time settings are essential for logs, certificates, network services, databases, and authentication processes. On Ubuntu, you can manage the system clock with timedatectl and use NTP for automatic synchronization.
01 — View the Current Status
Start by viewing the current system time and synchronization status.
timedatectl
date
Understanding the output
- Local time is the current time calculated for the configured local time zone.
- Universal time is the current time in UTC.
- RTC time is the value stored in the hardware real-time clock.
- Time zone shows the selected zone and its UTC offset.
- System clock synchronized indicates whether the system clock has successfully synchronized with a time source.
02 — View Available Time Zones
List the available time zones, then search for the zone you need.
timedatectl list-timezones
timedatectl list-timezones | grep Tehran
03 — Set the Time Zone
Set the server time zone to Asia/Tehran, then review the result.
sudo timedatectl set-timezone Asia/Tehran
timedatectl
04 — Set Date and Time Manually
Before setting the clock manually, temporarily disable NTP so automatic synchronization does not immediately replace the value you set.
sudo timedatectl set-ntp false
Then set the date and time in the required format.
sudo timedatectl set-time "2026-09-02 16:30:00"
05 — Enable NTP
After a manual change, enable NTP again to keep the clock synchronized automatically.
sudo timedatectl set-ntp true
timedatectl status
06 — Check Time Synchronization
Check the systemd-timesyncd service and view synchronization details.
systemctl status systemd-timesyncd
timedatectl timesync-status
07 — Check the RTC
View the hardware real-time clock with the following command.
sudo hwclock --show
For Linux servers, keep the RTC set to UTC. This avoids issues when daylight-saving rules or the configured time zone change.
Troubleshooting
NTP is inactive
Confirm that NTP is enabled and check the status of systemd-timesyncd.
The clock has drifted
Check the synchronization state and allow the system time to synchronize with its configured time source.
Incorrect time zone
Use the time-zone list to select the correct identifier, then verify the setting with timedatectl.
VM time synchronization
Review the virtual machine time-sync settings when the guest clock is being changed by the hypervisor.
The NTP server is unreachable
Check network connectivity, DNS resolution, and any firewall rules that prevent access to the configured time server.
Best Practices
- Use NTP on production servers so the clock remains synchronized automatically.
- Keep the RTC in UTC on Linux servers.
- Verify the result with timedatectl after changing a time zone or synchronization setting.
- When Chrony is used on the system, let it manage time synchronization instead of running competing synchronization services.
Frequently Asked Questions
Why should NTP be disabled before setting the clock manually?
It prevents automatic synchronization from immediately replacing the manually entered value.
Why does the system report that the clock is not synchronized?
Check that NTP is active, systemd-timesyncd can run, and the server can reach its configured time source.
Should the RTC use local time on a Linux server?
No. Keeping the RTC in UTC is the recommended approach for Linux servers.
Conclusion
With timedatectl, you can review and set the Ubuntu system clock, choose the correct time zone, and enable NTP synchronization. Verifying the synchronization status and keeping the RTC in UTC helps maintain reliable timekeeping on servers.