How to Check NTP Version in Linux

Cover Image for How to Check NTP Version in Linux

Accurately keeping time on your Linux machines is crucial for everything from debugging issues to timestamping files correctly. The Network Time Protocol (NTP) is the standard protocol used to sync time between servers and systems over a network.

Knowing which version of NTP your Linux distribution has installed can ensure you have the latest security patches and features.

Thankfully, checking the NTP version is a simple process.

Why Check the NTP Version?

There are a few reasons why you may want to verify the exact NTP version running on your Linux computers:

  • Security Updates - Like any software, new versions of NTP often contain important security and bug fixes. Outdated NTP daemons could have vulnerabilities that leave your systems open to attacks that tamper with the clock.

  • Feature Improvements - Upgrading to newer NTP releases can provide better clock precision, faster syncs, and useful enhancements like hardware timestamping.

  • Compatibility - If you are having time sync issues between servers, differing NTP versions could be the culprit. Making sure all systems run the same version can help troubleshoot problems.

So while NTP is generally set-it-and-forget-it software, periodically checking which release you have installed allows you to take advantage of the latest features and security of this critical utility.

NTP Versioning

The NTP project has been under development since before most Linux distributions existed. Here is a brief history of major releases:

  • NTP v1 - The original 1992 release of NTP by Professor David L. Mills.

  • NTP v2 - A complete rewrite in 1993, improving accuracy.

  • NTP v3 - Introduction of NTPv4 specification in 1995.

  • NTP v4 - Current production release, first launched in 2010, it is regularly updated with new point versions.

In almost all cases, you will be running NTP v4.x on a modern Linux system. The "x" represents the latest point release which contains incremental fixes and improvements. For example, NTP v4.2.8 was released in 2017 while NTP v4.2.8p15 came out in 2021.

Now let's go over the different methods to check exactly which release you have installed.

Using ntpq

The quickest way to find your NTP version is by using the ntpq command included in the standard NTP package.

ntpq is the query utility that can interrogate the currently running ntp background processes about their status. Using the -c flag, you can pass various arguments to get different details about the NTP daemon.

To check the version, run:

ntpq -c readvar version

This will query ntpd directly and print out the full version string:

ntpq -c readvar version
version="ntpd 4.2.8p15 2021/06/14"

The key details here are "ntpd 4.2.8p15" which shows the major version 4, minor version 2, patch release 8, and patch revision 15.

Using ntpq is the preferred option as queries executed locally avoid any networking issues. Next, we will look at some alternate methods that rely on outbound requests instead.

Query the Running NTP Process

The ntpd process itself also reports the version if queried directly. The PID of the currently running ntpd service can be found by running:

pidof ntpd

Take this PID and pass it to ps:

ps -p <PID> -o comm=

Which prints the full command line invocation used to start ntpd, including any arguments. The version flag will explicitly show the release:

/usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 108:114 -i /var/lib/ntp -d

In this case, ntpd 4.2.8p15 is running. This method works well but involves extra steps compared to using ntpq it alone.

Check Installed NTP Package Version

All Linux distributions package NTP into files that can be installed or updated through the system’s package manager.

These tools also track the version information of installed packages. Use the appropriate command to query for ntp or ntpd and it will return the release currently in place.

On Debian/Ubuntu systems:

apt list --installed | grep ntp

CentOS/RHEL systems:

yum list installed ntp

And Arch Linux:

pacman -Q ntp

While this shows the version of NTP included with the Linux distribution, it may differ from the actual binaries if you have compiled your own updated ntp packages from the source. Running either ntpq or inspecting the active ntpd process directly is best to determine the exact code currently keeping time.

Network Requests to the NTP Daemon

Lastly, a final check is to have an outside system send an NTP status request packet to your server. Tools like ntpdc those included in the NTP package can connect and interrogate for information. An example command is:

ntpdc -n -c sysinfo <your_ntp_server_ip>

This reaches out to the configured NTP daemon, and requests version metadata, but requires additional networking and firewall rules to allow traffic. Using one of the direct local checks within your own server is simpler.

Summary

Keeping your NTP server software up-to-date is recommended both for the latest features and minimizing security risks from potential vulnerabilities in outdated code. Finding your current NTP version in Linux is easy once you know where to check - no guessing is required.

The ntpq the tool runs local queries to the active ntpd process providing the canonical version details. For quick command line checks, this is the best approach requiring no additional networking or process inspection.

Understanding the release differences allows you to upgrade older daemons and enjoy better precision timekeeping across your infrastructure.


Also read -

Getting Started with NetworkManager on Kali Linux

Mounting NFS Shares from a Linux Server on Windows 2012

Getting Started with Metasploit Framework on Kali Linux