How to Set Time, Timezone and Synchronize System Clock Using timedatectl Command?

The timedatectl command allows you to query and change the configuration of the system clock and its settings, you can use this command to set or change the current date, time, and timezone or enable automatic system clock synchronization with a remote NTP server.

In this tutorial, am going to take you through the ways you can manage time on your Linux system by setting the date, time, timezone, and synchronize time with NTP from the terminal using the new timedatectl command.

It is always a good practice to maintain the correct time on your Linux server or system and it can have the following advantages:

  • maintain a timely operation of system tasks since most tasks in Linux are controlled by time.
  • the correct time for logging events and other information on the system and many more.

How to Find and Set Local Timezone in Linux

1. To display the current time and date on your system, use the timedatectl command from the command line as follows:

# timedatectl  status
Check Time and Date

In the screencast above, RTC time is the hardware clock time.

2. The time on your Linux system is always managed through the timezone set on the system, to view your current timezone, do it as follows:

# timedatectl 
# timedatectl | grep Time
Check Linux Time Zone

3. To view all available timezones, run the command below:

# timedatectl list-timezones
List All Timezones in Linux

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

# timedatectl list-timezones |  egrep  -o "Asia/B.*"
# timedatectl list-timezones |  egrep  -o "Europe/L.*"
# timedatectl list-timezones |  egrep  -o "America/N.*"
Find Local Timezone in Linux

5. To set your local timezone in Linux, we will use the set-timezone switch as shown below.

# timedatectl set-timezone "Asia/Karachi"
Set Local Timezone in Linux

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

# timedatectl set-timezone UTC
Set UTC Time in Linux

You need to type the correct name timezone otherwise you may get errors when changing the timezone, in the following example, the timezone “Asia/Kolkata” is not correct therefore causing the error.

Set Correct Timezone in Linux

How to Set Time and Date in Linux

6. You can set the date and time on your system, using the timedatectl command as follows:

Set Time in Linux

To set time only, we can use a set-time switch along with the format of time in HH:MM:SS (Hour, Minute, and Seconds).

# timedatectl set-time 15:58:30
Set Local Time in Linux
Set Date in Linux

7. To set date only, we can use a set-time switch along with the format of date in YY:MM:DD (Year, Month, Day).

# timedatectl set-time 20151120
Set Date in Linux

8. To set both date and time:

# timedatectl set-time '2015-11-20 16:14:50'
  • set-time, set-date, server-time, set-server-date-and-time
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to access VPS by SSH for first time?

You need to download latest version of Putty.exe file here: Open...

What is the requirements to Buy Pakistan Hosted VPS?

We Provide Pakistan Hosted VPS Servers only to Pakistani Customers. VPS Servers are hosted in...

How to change SSH Port in CentOS?

Connect to your server via SSH as root user. Run the following command: vi...

How to change server root password using SSH or VPS Portal?

Connect to your server via SSH as root user. Enter the command:passwd Type your password,...

How to Install CSF firewall in cPanel?

CSF firewall is fairly easy to install and require only few steps through SSH. Please follow the...