How to Set Timezone and Sync Server Time with NTP in Linux

Readers of this article will learn what the NTP is, how to sync your server time and date, and how to set the timezone in Linux.

You can easily keep your systemโ€™s date and time accurate by using NTP (Network Time Protocol). It lets you synchronize computer clocks through network connections and keep them accurate. A client requests the current time from a remote server and uses it to set its clock.

How to Synchronize Time with NTP Using systemd

The majority of Linux distributions have adopted systemd, and with it comes the systemd-timesyncd daemon.

That means you have an NTP client already preinstalled, and there is no need to run the full-fledged NTPD daemon anymore. Instead, the built-in systemd-timesyncd can do the primary time synchronization job fine.

To check the current status of time and time configuration via timedatectl, run the following command:

timedatectl status
Checking timedatectl status

If you see NTP service: active in the output, your computer clock is automatically adjusted through NTP.

If you see NTP service: inactive, run the following command to enable NTP time synchronization.

timedatectl set-ntp trueCode language: JavaScript (javascript)

Thatโ€™s all you have to do. Everything should be in place once thatโ€™s done, and time should be kept correctly.

In addition, timesyncd itself is still a normal service, so you can also check its status more in detail.

systemctl status systemd-timesyncd
Checking timedatectl sevice status

If it is disabled, you can start and make the systemd-timesyncd service active like this:

systemctl start systemd-timesyncd
systemctl enable systemd-timesyncd

How to Set/Change Timezone on Linux

Before changing your time zone, start using timedatectl to determine the currently set time zone.

timedatectl
View timezone on Linux

Now let’s list all the available time zones, so you know the exact name of the time zone you’ll use on your system.

timedatectl list-timezonesCode language: PHP (php)
List timezones on Linux

The list of time zones is quite extensive. First, however, you need to know the official timezone name for your location.

Another way to find your timezone is to list (ls -l) the contents of the /usr/share/zoneinfo/ directory. Find your preferred timezone (/usr/share/zoneinfo/Zone/SubZone) where Zone/SubZone is your selection, such as America/New_York, Europe/Paris, Asia/Bangkok, and so on. You got the idea.

Say you want to set the timezone on your Linux system to New York. The command should be like this:

timedatectl set-timezone America/New_YorkCode language: JavaScript (javascript)

This command creates a symbolic link for the time zone you choose from /usr/share/zoneinfo/ to /etc/localtime.

In addition, you can skip the command shown above, create this symbolic link manually and achieve the same result.

ln -s /usr/share/zoneinfo/America/New_York /etc/localtime

Here’s the man page for the timedatectl command if you need it.

Bobby Borisov

Bobby Borisov

Bobby, an editor-in-chief at Linuxiac, is a Linux professional with over 20 years of experience. With a strong focus on Linux and open-source software, he has worked as a Senior Linux System Administrator, Software Developer, and DevOps Engineer for small and large multinational companies.

Think You're an Ubuntu Expert? Let's Find Out!

Put your knowledge to the test in our lightning-fast Ubuntu quiz!
Ten questions to challenge yourself to see if you're a Linux legend or just a penguin in the making.

1 / 10

Ubuntu is an ancient African word that means:

2 / 10

Who is the Ubuntu's founder?

3 / 10

What year was the first official Ubuntu release?

4 / 10

What does the Ubuntu logo symbolize?

5 / 10

What package format does Ubuntu use for installing software?

6 / 10

When are Ubuntu's LTS versions released?

7 / 10

What is Unity?

8 / 10

What are Ubuntu versions named after?

9 / 10

What's Ubuntu Core?

10 / 10

Which Ubuntu version is Snap introduced?

The average score is 69%