NTP is a protocol that allows a machine to synchronize time over network connection. It basically works in client-server model, in which the client requests current time from a server, then it uses that data to set its own clock. NTP operates on the TCP/IP network suite and is one of the oldest part of the suite.
In a computer, inaccurate time can cause a lot of issues. Programs that relies on time to perform certain tasks can malfunction or fail to execute the actions. On distributed calculations, time is an essential indicator for the machines to operate peacefully with each other. System logging, performance monitoring, system maintainance tasks, network management system, all of these tasks rely on the precision of system time.
In this article, we will show you how to install NTP client and configure it to sync system time with upstream servers on Ubuntu. The guide is applicable to older versions of Ubuntu and many as well as Linux distros based on Ubuntu, such as Linux Mint or Pop! OS.
Update the system
Before installing any new package or application, it is recommended that you update your system. To do this, run the commands below which invoke
apt package manager to fetch a fresh package list from Ubuntu repository.
sudo apt update
Install NTP client
NTP package is available by default on Ubuntu default repository. The package contains a program to synchronize system time by calling
sntp from a command line.
sudo apt-get install ntp -y
Once the installation completes, you can confirm the installation by checking SNTP version :
Configure NTP to sync system time from upstread servers
SNTP, by default, fetches and verifies system time with 4 NTP pool servers, configured inside
/etc/ntp.conf file. These usually works fine, but in case you need quick time synchronizing or having trouble connecting to thoseservers, you can replacing default servers with the ones that are closest to your location.
Let us introduce you to NTP Pool Project project – a huge worldwide cluster of time servers that provides easy access to known “good time” for tens of millions of clients around the world.
The first thing you need to do is head over to the NTP Pool Project website to find the closest NTP server pool to your country. After that, we can use this information to edit
sudo nano /etc/ntp.conf
In this example, we’re replacing NTP pool list in Singapore to the configuration files as shown below:
Code language: CSS (css)
server 0.sg.pool.ntp.org server 1.sg.pool.ntp.org server 2.sg.pool.ntp.org server 3.sg.pool.ntp.org
Remember not to delete the
pool ntp.utuntu.com line, as it serves as the fallback in case the main servers go down or disconnected.
Finally, you have to restart the NTP service for the changes to take effect:
sudo systemctl restart ntp
We hope that the information above helped you successfully install NTP and configure it to synchronize system time and date from upstream servers in the internet. You may be interested in our other Linux software roundups, including 8 Best Open Source CMDB software, Best Linux Video Converters or Best Python Graphics Libraries. If you have any suggestion, please feel free to leave a comment below.