Yes, timedatectl is the standard command-line tool in Linux for controlling the system time, date, time zone, and NTP synchronization. It is available on all systemd-based distributions, including most modern versions of Ubuntu, Debian, Fedora, RHEL, and Arch Linux. This article explains how to view and change these settings, troubleshoot common issues, and understand the underlying mechanisms.
Background: Why timedatectl Exists
Before systemd, Linux systems used a mix of tools like date, hwclock, and ntpdate to manage time. The date command could set the system clock, but it had no unified way to handle time zones or enable NTP. Administrators had to manually edit /etc/timezone or symlink /etc/localtime and configure NTP daemons separately. timedatectl was introduced with systemd to provide a single, consistent interface for all time-related settings. It also integrates with systemd-timesyncd, a lightweight NTP client, making it easier to enable automatic time synchronization without installing additional packages.
How timedatectl Works
The tool reads and writes systemd's internal time management data, which is stored in /etc/localtime (a symlink to a time zone file) and in the kernel's system clock. It interacts with the hardware clock (RTC) through the hwclock interface and communicates with systemd-timesyncd for NTP. When you run timedatectl without arguments, it displays the current status:
Local time: Wed 2025-04-09 14:32:05 UTC Universal time: Wed 2025-04-09 14:32:05 UTC RTC time: Wed 2025-04-09 14:32:05 Time zone: Etc/UTC (UTC, +0000)System clock synchronized: yes NTP service: active RTC in local TZ: no
The output shows the local time, universal time (UTC), the hardware clock time, the configured time zone, whether the system clock is synchronized via NTP, and whether the RTC is set to local time (which is generally not recommended).
Basic Commands to View and Set Time
To view the current date and time, simply run timedatectl or timedatectl status. To set the date and time manually, you use the set-time command. The format is YYYY-MM-DD HH:MM:SS (24-hour). For example:
sudo timedatectl set-time '2025-04-09 15:30:00'
This sets both the system clock and, if the RTC is in UTC (the default), the hardware clock. If you only want to set the date or the time partially, you can use a shorter format like 2025-04-09 or 15:30:00. The command requires root privileges because it changes system-wide settings.
Managing Time Zones
To list all available time zones, run timedatectl list-timezones. This outputs a long list of region/location names like America/New_York, Europe/London, and Asia/Tokyo. To set the time zone, use set-timezone with the exact zone name:
sudo timedatectl set-timezone America/Chicago
This updates the /etc/localtime symlink and immediately changes the local time display. You can verify the change with timedatectl. If you need to find your time zone, you can use timedatectl list-timezones | grep -i your_city or check /usr/share/zoneinfo.
Enabling and Disabling NTP Synchronization
Automatic time synchronization is handled by systemd-timesyncd. To enable it, run:
sudo timedatectl set-ntp true
This starts the NTP service and keeps the system clock in sync with internet time servers. To disable it, use set-ntp false. When NTP is enabled, manual time changes are ignored (the system will override them). If you need to set the time manually, you must first disable NTP. Note that systemd-timesyncd only works as a client; if you need to run an NTP server or use more advanced features, you may want to install chrony or ntpd and disable systemd-timesyncd.
Common Problems and Solutions
One frequent issue is the error “Failed to set time: Automatic time synchronization is enabled”. This happens when you try to run set-time while NTP is active. The fix is to disable NTP first, then set the time, and optionally re-enable NTP afterwards. Another common problem is the RTC being set to local time, which causes confusion when dual-booting with Windows. You can check this with timedatectl; if it says RTC in local TZ: yes, you can change it to UTC with:
sudo timedatectl set-local-rtc false
If you see “System clock synchronized: no” even with NTP enabled, check your network connection and DNS resolution. You can also check the status of systemd-timesyncd with systemctl status systemd-timesyncd and view logs with journalctl -u systemd-timesyncd.
Comparison with Other Time Tools
While timedatectl is the recommended tool on systemd systems, other commands still exist. The date command can display and set the system time (e.g., date -s '2025-04-09 15:30:00'), but it does not manage time zones or NTP. hwclock directly reads and sets the hardware clock. ntpdate (deprecated) and chrony are NTP clients; chrony is often preferred for its better accuracy and faster synchronization. On non-systemd distributions (like older Slackware or Alpine), you may need to use these alternatives. However, for most modern Linux users, timedatectl is the simplest and most complete solution.
Safety and Best Practices
Changing the system time can affect logs, scheduled tasks (cron), and security protocols like Kerberos. Always set the time zone correctly before setting the time, and prefer using NTP over manual setting when possible. If you must set the time manually, ensure NTP is disabled and be aware that the change may cause temporary inconsistencies. When dual-booting with Windows, keeping the RTC in UTC (the default on Linux) is recommended; Windows can be configured to use UTC as well. Also, be careful with set-local-rtc true — it can cause issues with time synchronization and is generally not recommended.
Frequently Asked Questions
How do I check the current time zone in Linux?
Run timedatectl and look at the “Time zone” line. It shows the current zone and UTC offset. Alternatively, you can use cat /etc/timezone on Debian/Ubuntu or readlink /etc/localtime on other systems.
Why does my system time revert after reboot?
This usually indicates the hardware clock is set incorrectly or the RTC is in local time while the system expects UTC. Use timedatectl to check the RTC status. If it says RTC in local TZ: yes, run sudo timedatectl set-local-rtc false to set it to UTC. Also ensure the CMOS battery is not dead, as that would reset the hardware clock.
Can I use timedatectl to set the time without root?
No, changing the system time requires root privileges because it affects the entire system. You can view the status without sudo, but any modification (set-time, set-timezone, set-ntp) must be run with sudo or as the root user.
What is the difference between system time and hardware clock?
The system time is the kernel's current time, maintained in memory and updated by NTP. The hardware clock (RTC) is a battery-backed clock on the motherboard that keeps time even when the system is off. On boot, the system time is initialized from the RTC. timedatectl manages both, and you can see the RTC time in its output.
How do I force an immediate NTP sync?
With systemd-timesyncd, you can restart the service: sudo systemctl restart systemd-timesyncd. If you have chrony installed, use sudo chronyc makestep. Alternatively, you can temporarily disable NTP, set the time manually, and re-enable it.