How to Synchronize Time with NTP in Linux?

Time synchronization is a critical aspect of computer systems, ensuring that clocks are accurate and compatible with other systems on a network. Incorrect time can cause several issues, such as inconsistent data, incorrect timestamps on files, and security vulnerabilities. Linux offers various methods for synchronizing time with network time servers, with the Network Time Protocol (NTP) being the most widely used approach.

NTP is an open-source protocol that provides precise time synchronization between computer systems over packet-switched networks. This article will guide you through synchronizing time using NTP on Linux, covering installation, configuration, and status monitoring.

Installing NTP Services

Linux systems offer two primary NTP implementations: the traditional NTP daemon and the more modern Chrony. Both serve the same purpose but have different characteristics.

Installing Traditional NTP

First, update your package list and install the NTP package

sudo apt-get update
sudo apt-get install ntp

Once installed, NTP automatically synchronizes with default servers specified in /etc/ntp.conf. Most distributions use pool.ntp.org as the default time source.

Installing Chrony (Alternative)

Chrony is a modern NTP implementation that handles network jitter and delays more efficiently

sudo apt-get install chrony

Chrony maintains a high-resolution local clock and uses advanced algorithms to estimate and minimize offset between the local clock and time sources. It automatically starts synchronizing with servers configured in /etc/chrony/chrony.conf.

Configuring NTP Servers

To configure specific time servers, edit the NTP configuration file

sudo nano /etc/ntp.conf

Add or modify server entries to use reliable NTP Pool Project servers

server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
server 3.pool.ntp.org

NTP uses a hierarchical stratum system where Stratum 1 servers are directly connected to atomic clocks, Stratum 2 servers sync from Stratum 1, and so on. Pool servers automatically select the best available stratum level.

After editing the configuration, restart the NTP service

sudo service ntp restart

Starting and Managing NTP

Start the NTP service to begin time synchronization

sudo service ntp start

The service will automatically connect to configured time servers and begin periodic synchronization. NTP adjusts the system clock gradually to avoid sudden time jumps that could disrupt running applications.

Checking Synchronization Status

Monitor NTP synchronization using the ntpq command

ntpq -p

This displays a peer status table showing connected time servers

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+0.pool.ntp.org  .POOL.          16 p    -   64    0    0.000   -0.020   0.015
*1.pool.ntp.org  .POOL.          16 p    -   64    0    0.000   -0.021   0.015
+2.pool.ntp.org  .POOL.          16 p    -   64    0    0.000   -0.020   0.015
+3.pool.ntp.org  .POOL.          16 p    -   64    0    0.000   -0.022   0.015

Understanding the Output

Symbol Meaning
* Currently synchronized server
+ Good candidate for synchronization
- Server rejected by selection algorithm
x Server considered unreliable

Key columns include

  • delay Round-trip network delay to server

  • offset Time difference between local clock and server

  • jitter Variation in offset measurements over time

Monitoring Chrony Status

For Chrony users, check synchronization status with

sudo chronyc tracking

This shows current synchronization statistics and time source information, helping identify any synchronization issues.

Conclusion

NTP is essential for maintaining accurate time on Linux systems, ensuring proper network communication, security, and system reliability. By installing NTP or Chrony, configuring reliable time servers, and monitoring synchronization status, you can maintain precise timekeeping across your infrastructure. Regular monitoring ensures your system clock remains accurate and synchronized with authoritative time sources.

Updated on: 2026-03-17T09:01:39+05:30

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements