Skip to Content

2 ways to check NTP server in Linux

In this blog post, we will show you how to check the NTP server on Linux. This is an important task if you are running a server and need to make sure that your time is accurate. The NTP service can be used to synchronize the time on your computer with a time server. This can help ensure that your system is always running accurately and on schedule. Let’s take a look at how to check the NTP service on Linux!

What is NTP?

The Network Time Protocol (NTP) is a protocol used to synchronize the time on your computer with a time server. This can help ensure that your system is always running accurately and on schedule. By default, most Linux distributions come with the Network Time Protocol (NTP) service installed and running.

Check ntp server with ntpq command in Linux

The ntpq command is the best way to check ntp server in Linux. It can be used to get information about the NTP service, such as the server that it is using to synchronize the time.To do this, we can type in ‘ntpq -p’ in the terminal and press Enter.

This will list the NTP servers the system is synchronizing with:

remote      refid st t when poll reach delay  offset jitter
==============================================================================
*85.199.214.98  .GPS. 1 u 38  64  377 5.047 -0.184 0.131
+81.21.65.168   .STEP. 16 u – 1024   0 0.000  0.000 0.000
-178.79.155.116  .STEP. 16 u – 1024   0 0.000  0.000 0.000
81.21.76.27   .STEP. 16 u – 1024   0 0.000  0.000 0.000

The host addresses shown in the remote column should agree with the DNS entries in the configuration file, plus any peers not mentioned in the file at the same or lower than your stratum that happen to be configured to peer with you. Be prepared for surprises in cases where the peer has multiple addresses or multiple names. The refid entry shows the current source of synchronization for each peer, while the st reveals its stratum and the poll entry the polling interval, in seconds.

The when entry shows the time since the peer was last heard, normally in seconds, while the reach entry shows the status of the reachability register (see RFC-1305), which is in octal format. The remaining entries show the latest delay, offset and dispersion computed for the peer, in milliseconds.

The tattletale character at the left margin displays the synchronization status of each peer. The currently selected peer is marked *, while additional peers designated acceptable for synchronization, but not currently selected, are marked +. Peers marked * and + are included in a weighted average computation to set the local clock; the data produced by peers marked with other symbols are discarded. See the ntpq documentation for the meaning of these symbols.

The ‘ntpq’ command is a powerful tool that can be used to troubleshoot the NTP service. In order to use the ntpq command, we need to type in ‘ntpq -h’ and press Enter. This will show us all of the options that are available for the ntpq command.

3 ways to change time in Linux

Check ntp service with systemctl command in Linux

we can also use the command ‘sudo systemctl status ntp’ to check the status of the NTP service. This will give us more information about the service, including whether it is running or not.

The ‘systemctl’ command is a powerful tool that can be used to manage services on Linux. We can use the ‘systemctl status’ command to check the status of a service. This will tell us whether the service is running or not.

We can also use the ‘systemctl start’ and ‘systemctl stop’ commands to start and stop services. In this case, we would use the ‘sudo systemctl start ntp’ and ‘sudo systemctl stop ntp’ commands to start and stop the NTP service.

We can use the ‘systemctl enable’ command to enable a service to start automatically at boot time. In this case, we would use the ‘sudo systemctl enable ntp’ command to enable the NTP service.

We can also use the ‘systemctl disable’ command to disable a service from starting automatically at boot time. In this case, we would use the ‘sudo systemctl disable ntp’ command to disable the NTP service.

how to change ntp server in Linux

In order to change the NTP server that is used by the NTP service, we can use the ‘ntpdate’ command. This command can be used to set the time on your computer using a time server. We can use the ‘ntpdate’ command to change the NTP server that is used by the NTP service. To do this, we will type in ‘sudo ntpdate time.nist.gov’ and press Enter. This will change the NTP server to the National Institute of Standards and Technology (NIST) time server.

We can also change the ntp server in Linux by editing the ‘/etc/ntp.conf’ file. This file contains a list of all of the available time servers. We can add or remove servers as needed.

How to use multiple NTP servers at once?

Yes, you can use multiple time servers at once by adding them to the ‘/etc/ntp.conf’ file. You can add or remove servers as needed.

What is the default polling interval for the NTP service?

The default polling interval is 64 seconds. This can be changed by editing the ‘/etc/ntp.conf’ file.

Which is better, a manually configured ntp service or an automatic one?

It depends on your needs. If you need more control over the NTP service, then you should configure it manually. If you don’t need as much control, then an automatic configuration may be better.You can find more information about the NTP service in the ‘/etc/ntp.conf’ file. This file contains a list of all of the available time servers. You can add or remove servers as needed.

What is the ‘driftfile’ for NTP

The driftfile is used by the NTP service to store the current time offset. This file is located at ‘/var/lib/ntp/drift’.

Why is my ntp server not working?

  • There are a few reasons why your ntp server may not be working. First, make sure that you have added the correct server to the ‘/etc/ntp.conf’ file. You can add or remove servers as needed.
  • Second, make sure that your firewall is configured to allow traffic on port 123 UDP.
  • Third, make sure that the NTP service is running. You can check the status of the service with the ‘sudo systemctl status ntp’ command.
  • If you are still having trouble, you can try using a different time server. You can find a list of available time servers at ‘/etc/ntp.conf’.

 

The NTP service is a vital part of keeping your computer’s time accurate. By using the ‘ntpq’ and ‘systemctl’ commands, we can easily check the status of the NTP service and change the NTP server if necessary. With a few simple commands, we can ensure that our computer is always running on schedule.

That’s all there is to it! In this blog post, we have shown you how to check the NTP service on Linux. This is an important task if you are running a server and need to make sure that your time is accurate. The NTP service can be used to synchronize the time on your computer with a time server. This can help ensure that your system is always running accurately and on schedule. Thanks for reading!

3 ways to get time in Linux