Use Timedatectl to Control Time, Date, and More in Linux

Linux Timedatectl Command Featured

Keeping our date and time settings accurate in Linux is extremely important for the smooth functioning of system tasks. The timedatectl command in Linux allows you to query and change the system clock and its various associated settings. It comes as part of systemd and provides a simple way to ensure your system reports the right date and time. Here we show you how to use timedatectl to control the time and date on your Linux machine.

Tip: You can also use systemd timer as a cron replacement.

System Clock vs. Real-Time Clock (RTC)

Your Linux system uses two different clocks to keep track of time – system clock and real-time clock.

The system clock or the software-managed clock is maintained by your operating system or the Linux kernel. It needs help from the real-time clock to get the initial value during a system boot.

The real-time clock or RTC is a hardware clock on your motherboard and remains active even when the system is turned off. It uses a battery to keep it running continuously so it can track the time and inform the system of the correct time during the boot.

The timedatectl command helps you to manage both these clocks.

Display System Date and Time With timedatectl

The timedatectl command is one of the most useful Linux commands. To simply check the current date and time on your Linux system, type in the timedatectl command without any other parameters and press Enter. The output will display the local time, universal time, RTC time, time zone, and some other pieces of useful information.

Linux terminal screenshot showing timedatectl output

While the Local time (based on the system time zone), Universal time, and RTC time entries are self-explanatory, the Time zone entry refers to the time zone that is currently set in the system.

The other items inform you whether the system clock is synchronized with an NTP server (for real-time update using the internet), whether that NTP service is active, and whether the RTC is using the local time instead of UTC.

Update System Time Zone With set-timezone

Depending on the time zone your Linux system is using, the system clock might not show the correct local time.

To check the time zone your system is using, refer to the Time zone line in the output in the previous section. For instance, my system is using the US/Eastern (EST, -0500) time zone. The -0500 offset refers to the difference from the UTC or the universal time.

If you want to change the time zone, first query the system for a list of available time zones you can use:

timedatectl list-timezones

It will generate a long list and will take a long time for you to scroll through. For a more practical output, you can modify the command to limit the results to your local region or country:

timedatectl list-timezones | grep "America/" | less
Linux terminal screenshot showing the various time zones

To change the system’s current time zone, you can use the set-timezone parameter as follows:

timedatectl set-timezone "America/Chicago"

The system might prompt you to enter your password as the command requires elevated privileges to execute. Once done, you can verify the change by simply executing timedatectl again.

Linux terminal screenshot showing how to change time zone

You can see that the output reports the new time zone that was updated in the previous command. If you prefer, you can even set multiple timezones in Ubuntu and other Linux distros for a quick glance at multiple time zones at once.

Set System Date and Time Manually With set-time

In most cases, your system will synchronize the system clock with an NTP server on startup, so your system time and date are always correct. However, in the event that your system don’t have access to the Internet, you can still use the set-time parameter to manually set a new date or time.

To manually set the system date and time, first disable the synchronization with the NTP server:

sudo systemctl disable --now chronyd

Next, set the new date and time using the following command:

timedatectl set-time "2023-11-16 10:00:00"
Linux terminal screenshot showing how to set date and time manually

Configure Real-Time Clock With timedatectl

You can also configure the real-time clock of your system. By default, the RTC is synced to the universal time or UTC, but it’s possible to set it to your local time zone.

One thing to note is that maintaining the RTC in the local time zone can create various problems with time zone changes and daylight saving adjustments. Your system might also display a similar warning if you change the RTC to your local time zone.

In any case, if you still want to set the RTC to your local time zone, execute the following command:

timedatectl set-local-rtc 1
Linux terminal screenshot showing how to set RTC time

If you want to set the RTC back to UTC again, simply replace 1 with 0 in the same command.

Note: If you dual-boot your computer with Windows and Linux, you might come across a scenario where the system clocks are not synchronized. Here is how you can fix it.

Synchronize System Clock With NTP

NTP, or Network Time Protocol, is an internet protocol for clock synchronization between a wide network of computers over the internet. It is intended to synchronize all participating computers to within a few milliseconds of UTC.

To be able to synchronize the system clock with an NTP server, you must have NTP installed on your system. You can simply execute the installation command to do this:

sudo apt-get -y install ntp
Linux terminal screenshot showing how to synchronize time with NTP

Now, to enable automatic synchronization with an NTP server, execute the following command:

timedatectl set-ntp true
Linux terminal screenshot showing how to enable NTP service

Similarly, you can disable NTP synchronization by using the following command: timedatectl set-ntp false.

Manage System Time & Date With timedatectl

The timedatectl command is a handy tool for you to adjust your system clock and RTC configurations as well as set the required time zone if you’ve moved or are traveling. If you are always on the move, you will want to make use of these time zone converters for easy scheduling of tasks.

All screenshots by Tanveer Singh.

Is this post useful?
Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Tanveer Singh
Tanveer Singh - Staff Writer

After a 7-year corporate stint, Tanveer found his love for writing and tech too much to resist. An MBA in Marketing and the owner of a PC building business, he writes on PC hardware, technology, video games, and Windows. When not scouring the web for ideas, he can be found building PCs, watching anime, or playing Smash Karts on his RTX 3080 (sigh).