Oracle by Example brandingOracle Linux: Update the System Date and Time From the Command Line Interface

section 0Before You Begin

This tutorial describes how to update the system date and time on an Oracle Linux system from the command line. It also describes how to configure the chrony time synchronization service. This tutorial is targeted at Oracle Linux 8 users, but the timedatectl command can be used on other systems where systemd is installed, such as Oracle Linux 7.


Many Oracle Linux systems are installed without a desktop environment. However, multiple ways using command lines are available to configure base system settings, such as the system date and time.

On Oracle Linux systems, use the timedatectl command to set the system date and time. The command updates the real time clock (RTC), also known as the hardware clock, as well as the system clock that is maintained by the system kernel.

To ensure that your system time is accurate, enable the chrony NTP service and configure it to access configured NTP servers.

What Do You Need?

  • Any Oracle Linux system that uses systemd
  • Network access to an NTP server (optional)

Check the current configuration

To check the current date and time configuration for a system, run the timedatectl command without any parameters, for example:

$ sudo timedatectl
               Local time: Thu 2019-08-01 16:52:05 BST
           Universal time: Thu 2019-08-01 15:52:05 UTC
                 RTC time: Thu 2019-08-01 15:52:05
                Time zone: Europe/London (BST, +0100)
System clock synchronized: no
              NTP service: inactive
          RTC in local TZ: no

The system displays information about the current date and time configuration.

Note that if the NTP service is set to active, your system's date and time are automatically synchronized with the configured NTP server. Therefore, you would be unable to directly modify the date or time on your system.

Set the system time zone

Set the system time zone by running the following command:

$ sudo timedatectl set-timezone region/city

Substitute region/city with the value for your global region and the closest major city to your location.

To obtain a listing of available time zones, run this command:

$ sudo timedatectl list-timezones

As an option, use grep city to narrow your search. Use the underscore (_) for cities with compound names. For example, for a setting that uses Pacific Daylight Time (PDT), you might make the following search:

$ sudo timedatectl list-timezones | grep 'San_Francisco'
$ sudo timedatectl list-timezones | grep 'Los_Angeles'

Based on the search results, you would use America/Los_Angeles for your region/city. Note that other cities can also be valid for a PDT setting, such as America/Vancouver.

Set the system date and time

If you do not have an NTP service configured and enabled, you can manually set the system date and time running the following command:

$ sudo timedatectl set-time YYYY-MM-DD hh:mm:ss

Substitute YYYY-MM-DD hh:mm:ss with the respective values for the current year, month, day, hour, minute and second.

The command also works if you specify only a date change or only a time change. Both commands are valid:

$ sudo timedatectl set-time YYYY-MM-DD


$ sudo timedatectl set-time hh:mm:ss

The date and time values are updated for both the RTC and the system clock.

Configure the system to synchronize with a network time service

Oracle Linux 8 ships with the chrony network time service by default. If the service is not available on the system, install the package first. Otherwise, the commands in these examples fail.

$ sudo dnf install chrony

To enable and run the NTP service, run the following command:

$ sudo timedatectl set-ntp yes


$ sudo systemctl enable --now chrony

The date and time values are automatically synchronized with the configured NTP servers.

To change the NTP servers with which your system is synchronized, edit the /etc/chrony.conf file.

See the chrony.conf(5) manual page for more information about configuring this service.

more informationWant to Learn More?