timedatectl – Used to set or query system time, date and time zone configuration

The timedatectl command is used to set or query the system time, date, and time zone configuration in Linux. It is a part of the systemd suite of system management tools and is available on most modern Linux distributions.

To view the current time and date settings, simply run the timedatectl command with no arguments:

$ timedatectl
      Local time: Fri 2021-07-23 15:50:27 UTC
  Universal time: Fri 2021-07-23 15:50:27 UTC
        RTC time: Fri 2021-07-23 15:50:27
       Time zone: Etc/UTC (UTC, +0000)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

The output shows the local time, universal time, RTC (real-time clock) time, time zone, and NTP (Network Time Protocol) status.

To set the system time and date, use the set-time and set-date options, respectively:

$ sudo timedatectl set-time "2021-07-23 15:55:00"
$ sudo timedatectl set-date "2021-07-23"

To set the time zone, use the set-timezone option followed by the name of the time zone:

$ sudo timedatectl set-timezone America/New_York

You can also list all available time zones by running:

$ timedatectl list-timezones

Options

The following options are available for the timedatectl command:

Option Description
status Show the current time and date settings.
set-time TIME Set the system time. The TIME argument must be in the format YYYY-MM-DD HH:MM:SS.
set-timezone TIMEZONE Set the system time zone. The TIMEZONE argument must be a valid time zone name, such as America/New_York.
set-local-rtc BOOL Set whether the RTC is in local time. The BOOL argument must be yes or no.
list-timezones List all available time zones.
help Show help information.

Troubleshooting Tips

  • If you receive an error message when trying to set the time or date, make sure you have sufficient privileges to do so. Running the command with sudo should resolve this issue.
  • If the system clock is consistently incorrect, ensure that the NTP service is enabled and running. You can check the status of the NTP service by running timedatectl.

Notes

  • Changes made with timedatectl are persistent across reboots.
  • The timedatectl command requires the systemd system and service manager to be installed on the system.