How To Configure NTP Server to Synchronize Time in Linux

Synchronizing Time with NTP Server in Ubuntu / Linux Mint / Xubuntu / Debian

Time synchronization is very important in order to determine when events happen in our system. You would like to have your system time to be accurate. The Network Time Protocol (NTP) helps you to keep your system clock updated and contacts its servers around the world depending upon the configuration and you may also configure it manually. To do so you need to edit default configuration file in /etc/ntp.conf file and then it will fetch the local time. The Network Time Protocol uses UDP port 123.

To Install

First open terminal and enter the following command to install NTP.

In case any error update your packages list or check your sources.list file at /etc/apt/ path.

root@linuxhelp:~# apt-get install ntp
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libavahi-client-dev libavahi-common-dev libavahi-compat-libdnssd1
  libdbus-1-dev libntdb1 libruby2.1 libyaml-0-2 python-ntdb ruby2.1
  rubygems-integration
Use ' apt-get autoremove'  to remove them.
The following extra packages will be installed:
  libopts25
Suggested packages:
  ntp-doc
The following NEW packages will be installed:
  libopts25 ntp
.
.
.
Processing triggers for systemd (225-1ubuntu9) ...


Check NTP service status by running the following command.

root@linuxhelp:~# service ntp status
? ntp.service - LSB: Start NTP daemon
   Loaded: loaded (/etc/init.d/ntp)
   Active: active (running) since Sat 2016-05-07 09:45:58 IST  36s ago
     Docs: man:systemd-sysv-generator(8)
   CGroup: /system.slice/ntp.service
           ??9078 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 121:129
May 07 09:45:58 linuxhelp ntpd[9078]: proto: precision = 0.164 usec
May 07 09:45:58 linuxhelp ntpd[9078]: ntp_io: estimated max descriptors: 10...16
May 07 09:45:58 linuxhelp ntpd[9078]: Listen and drop on 0 v4wildcard 0.0.0...23
May 07 09:45:58 linuxhelp ntpd[9078]: Listen and drop on 1 v6wildcard :: UDP 123
May 07 09:45:58 linuxhelp ntpd[9078]: Listen normally on 2 lo 127.0.0.1 UDP 123
May 07 09:45:58 linuxhelp ntpd[9078]: Listen normally on 3 eno16777736 192....23
May 07 09:45:58 linuxhelp ntpd[9078]: Listen normally on 4 lo ::1 UDP 123
May 07 09:45:58 linuxhelp ntpd[9078]: Listen normally on 5 eno16777736 fe80...23
May 07 09:45:58 linuxhelp ntpd[9078]: peers refreshed
May 07 09:45:58 linuxhelp ntpd[9078]: Listening on routing socket on fd #22...es
Hint: Some lines were ellipsized, use -l to show in full.
NTPQ command utility is used to monitor NTP daemon and it’ s performance can be displayed using the command.
root@linuxhelp:~# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 125.62.193.121  204.152.184.72   2 u   65   64    3   46.121   25.726   0.125
 123.108.200.124 83.137.225.123   3 u   63   64    3   75.791   -9.424  17.527
 juniperberry.ca 193.79.237.14    2 u   61   64    3  151.195   -4.491  16.551


You can also check the synchronization of ntp logs using the command.

root@linuxhelp:~# tail -f /var/log/syslog
May  7 09:45:58 linuxhelp ntpd[9078]: Listen and drop on 1 v6wildcard :: UDP 123
May  7 09:45:58 linuxhelp ntpd[9078]: Listen normally on 2 lo 127.0.0.1 UDP 123
May  7 09:45:58 linuxhelp ntpd[9078]: Listen normally on 3 eno16777736 192.168.5.147 UDP 123
May  7 09:45:58 linuxhelp ntpd[9078]: Listen normally on 4 lo ::1 UDP 123
May  7 09:45:58 linuxhelp ntpd[9078]: Listen normally on 5 eno16777736 fe80::20c:29ff:fe28:2907 UDP 123
May  7 09:45:58 linuxhelp ntpd[9078]: peers refreshed
May  7 09:45:58 linuxhelp ntpd[9078]: Listening on routing socket on fd #22 for interface updates
Tag : NTP Server
FAQ
Q
which command use to start the service of NTP package in ubuntu?
A
use the following command to start the service of NTP package in ubuntu
# systemctl start ntpd
# systemctl enable ntpd
Q
How to add NTP port to be allow for the ubuntu?
A
ypou can use the folowing command to allow port for ntp
# firewall-cmd --add-service=ntp --permanent
# firewall-cmd --reload
Q
where to check the NTP log file in ubuntu?
A
by using following command to see the log file for ntp in ubuntu
# tail -f /var/log/syslog
Q
Which package to install NTP on ubuntu?
A
use the following command to install NTP on ubuntu
# apt-get install ntp
Q
How to configure NTP on Centos?
A
Refer our following link for configuring NTP for Centos,
https://www.linuxhelp.com/setup-ntp-server-network-time-protocol/