Readers of this article will learn what the NTP is, how to sync your server time and date using systemd-timesyncd network time service, 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
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:
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 true
That’s all you have to do. Everything should be in place once that’s done, and time should be kept correctly.
timesyncd itself is still a normal service, so you can also check its status more in detail.
systemctl status systemd-timesyncd
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.
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.
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 (
Zone/SubZone is your selection, such as
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_York
This command creates a symbolic link for the time zone you choose from
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.