How To Query Ntp Server Linux

Network Time Protocol (NTP) is a networking protocol for clock synchronization between computer systems over packet-switched, variable-latency data networks. In operation since before 1985, NTP is one of the oldest Internet protocols in current use. In Linux, querying an NTP server can be done using a variety of methods. In this blog post, we will look at how to query an NTP server using the ntpdate and ntpdc -c sysinfo commands.

ntpdate

The ntpdate command can be used to query an NTP server and display the results. This command also sets the system time to match the server time.

To use the ntpdate command, you first need to install the ntpdate package. The command to install ntpdate on Ubuntu or Debian-based systems is as follows:

    sudo apt-get install ntpdate
    

Once you have the ntpdate package installed, you can query an NTP server using the following command:

    ntpdate -q pool.ntp.org
    

This command queries the pool.ntp.org server and then displays the server time.

ntpdc -c sysinfo

The ntpdc -c sysinfo command can also be used to query an NTP server. This command provides detailed information about the server’s state.

To use the ntpdc -c sysinfo command, you first need to install the ntp package. The command to install ntp on Ubuntu or Debian-based systems is as follows:

    sudo apt-get install ntp
    

Once you have the ntp package installed, you can query an NTP server using the following command:

    ntpdc -c sysinfo pool.ntp.org
    

This command queries the pool.ntp.org server and then displays detailed information about the server’s state.

Conclusion

In this blog post, we have looked at how to query an NTP server using the ntpdate and ntpdc -c sysinfo commands in Linux. These commands allow you to synchronize your system time with a remote NTP server and gather detailed information about the server’s state.