Set The Date-Time Using Timedatectl Command

Linux Tutorials

June 2, 2020 by Harry Hill

How To Set Date-Time In CentOS

The Timedatectl command is one of the new tools for RHEL / CentOS 7 and Fedora 21+ distributions, which is part of the Systemd and service manager system, and we will use ut to set the date-time. And it is actually a replacement for the old and traditional date command used in the Sysvinit service in Linux distributions.

The Timedatectl command allows you to change the system clock configurations as well as its settings. You can use this date command on your system to define or change time and timezone and enable an automatic system clock, which is actually synchronized with NTP Server Remote.

In this article, we’re going to show you how to manage time on your Linux systems by setting the date, time, timezone, and syncing time using NTP and using the new Timedatectl command through the terminal.

What are the benefits of having the correct time zone on the server?

  • Existence of time-based performance of system tasks (since most tasks in Linux are controlled by time)
  • Set the date-time to create login event and other information on the system and …


How to find and define Local Timezone on Linux

To display the time and date on your system, run the timedatectl command as follows.

# timedatectl  status

See time using timedatectl on Linux

In the image above, RTC time is actually the hardware’s clock time.

Time on your Linux systems is always managed through the timezone defined on the system. To display timezone now, run the following command on your system.

# timedatectl
# timedatectl | grep Time

see time using timedatectl

Run the following command to display all available timezones.

# timedatectl list-timezones

List all timezones in Linux

To find the local timezone, run the following command according to your location.

# timedatectl list-timezones |  egrep  -o Asia/B.*
# timedatectl list-timezones |  egrep  -o Europe/L.*
# timedatectl list-timezones |  egrep  -o America/N.*

Display time-zone according to your location

To define your local timezone in Linux, we will use the set-timezone option as follows.

# timedatectl set-timezone Asia/Kolkata
# timedatectl

Set time-date zone on Linux

It is always recommended to use and define coordinated universal time, UTC.

# timedatectl set-timezone UTC

Set time to UTC

Note: You must enter the correct timezone name; otherwise, you will receive an error. For example, the timezone “Asia / Kalkata” is not right, giving an error.

How to set the date-time on Linux

You can use the timedatectl command to set the date-time on your system.

To set only time, the set-time option is used along with the time format, which is mostly HH: MM: SS (Hour, Minute, and Seconds).

# timedatectl set-time 15:58:30

Seti time in Linux

You may face the below error when running this command:

Failed to set time: NTP unit is active

It says that the NTP service is active. You can deactivate it using the below command.

# systemctl disable --now chronyd

To set the date only, the set-time option along with the date format in the form of YY: MM: DD (Year, Month, Day) is used.

# timedatectl set-time 2019-04-05

Set Date-time in Linux

To set the date-time, do the following.

# timedatectl set-time '16:10:40 2015-11-20'

Set date-time with each other

How to find and define Hardware Clock on Linux

The set-local-etc boolean-value option is used to set the Hardware Clock to UTC or coordinated universal time.
First, use the following command to determine if our hardware clock is defined as a local timezone.

# timedatectl | grep local

Define your hardware clock to the local timezone.

# timedatectl set-local-rtc 1

Find the hardware clock format

Set your hardware clock to coordinated universal time (UTC).

# timedatectl set-local-rtc 0
# timedatectl | grep local

Set UTC in Linux

Sync Linux system clock using a remote NTP server

NTP stands for Network Time Protocol and is actually an Internet protocol used to sync system clocks between computers. The Timedatectl tool allows you to automatically sync your Linux system clock using a group of remote NTP servers.

Please note that you must install NTP on the system to enable automatic sync time with NTP servers.
To start automatic synchronization time with the NTP remote server, enter the following command in the terminal.

# timedatectl set-ntp- true

Enable synchronization with NTP server in Linux

To disable NTP time synchronization, run the following command in the terminal.

# timedatectl set-ntp- false

Disable synchronization with NTP server in Linux


In this article, we have explained very easy examples, and we hope that it will be useful for you and that you can set the date-time and timezone of different Linux systems. To learn more about this tool, visit the Timedatectl man page.


About the Author Harry Hill

I like to learn and to teach to make things easier

Leave a Reply

Your email address will not be published. Required fields are marked *

Joe February 16, 2021 at 11:12 pm

In the first few photos you show the setting for System clock synchronized: set to yes than it changes to no and you do not address how or why you adjusted this setting, than it is changed back to Yes and again its not addressed. How do you toggle this setting from no to yes?

    Harry Hill February 22, 2021 at 7:34 am

    Hi dear Joe. The NTP service manages system clock synchronization, and when this service active, we face an error for setting time/date. To resolve this, we temporarily deactivate it using the command # systemctl disable --now chronyd and enable it again once we set the time, using the command # systemctl enable --now chronyd