Linux Commands

Ntpdate Command in Linux

NTP, which refers to Network Time Protocol, is employed to align the clocks among several machines. A group of machines is kept in sync with one another using an NTP server. You might synchronize to NTPD servers that are accessible through the internet, or you create your personal NTPD domain controller and set up the client PCs to synchronize the respective times to it. A utility to configure and update the date and time metadata using the NTP interface is the ntpdate instruction. To adjust the existing system date/time following the preset timezone data, ntpdate just inquiries the date and time-relevant data. The ntpdate utility operates and interacts across the network. And indeed, the date and time setting is appropriate if the network is functioning correctly and consistently.

Update and Upgrade

We need to start our article’s implementation by opening the shell application that is available in our Linux system terminal. After the application is successfully opened, utilize the “update” instruction in it to make your system fully updated using the utility “apt” with “sudo” rights. If it requires the password to continue, add your current user’s password and press the “Enter” key.

Now that your system is updated, spend a little time upgrading its kernel as well. For that, you have to replace the “update” keyword with the “upgrade” keyword within the same instruction and execute it using the “apt” utility command.

If it asks for confirmation like “Do you want to continue? [y/n]”, make sure to add “y” or “n” to confirm it or choose to discard the upgrade process, respectively.

After a while, it completes the processing and the system is upgraded perfectly.

Install the Ntpdate Utility

To get started with the use of the ntpdate command, we must install the ntpdate client package in our Linux system without any issues. As we have been working on the Ubuntu 20.04 LTS system, we must use the “apt” utility to install the ntpdate utility within the “install” query.

After all its processing is done, you will see that it will be installed and configured successfully at your end. It might take up to 20 seconds for its full completion.

After the successful and effective configuration of the ntpdate client utility on your Linux system, you now have to open a command-line interface console. To disable the Ubuntu’s standard timesyncd daemon is the initial step that we must do after loading the ntpdate tool since doing so prevents us from synchronizing with the Server. For this, you have to run the following instruction on the shell:

$ sudo timedatectl set-ntp off

All you have to do is execute the Linux query with the administrator privileges to coordinate your default settings with the global time servers. This query uses the “ntpdate” utility and a URL to the global time server, “ntp.ubuntu.com” as presented in the following image:

Configure NTPD

An additional effort is required if you wish to maintain synchronicity. Deployment and setup of the NTPD daemon are required tasks. To connect to a particular time domain controller via the internet, NTPD employs NTP (network time protocol). Eventually, this should maintain the system time synchronization without additional help from you. To install NTP on your system, try the “apt” utility within the installation command along with the “ntp” keyword.

The process of NTP installation might ask for confirmation. You need to confirm it using the “y” key referring to “yes” and press the “Enter” key to continue with the processing.

This process of installing NTP doesn’t take much of your time. You have to hardly wait for 1 to 2 minutes. The progress of the NTP installation is portrayed in the following attached image:

For the majority of the time, installing the ntp utility and leaving your NTP Daemon set as it was pre-installed is the only thing required to maintain your date and time in synchronization with the web regular time servers. While we trust the NTP server to keep track of the system time, it is wise to make sure that some parameters are in order. The ntp.conf document includes the configuration for these values. Open this configuration file within “nano” to update it.

Make sure to provide the correct path to the ntp.conf file residing in the “etc” folder of our system. Put the completely capable domain server title of the web host that we plan to employ in this document for harmonization. The standard settings, for instance, appear as follows:

To locate the NTP server stream that is most convenient for your region, examine the NTP Pool Site. Be careful to save the ntp.conf document after making any required adjustments. Then, close the file. The NTP server should then be restarted to make the modifications effective. Now, you have to start the NTP service using the systemctl instruction with its keywords “start” and “ntp”. After this, try enabling it using the “enable” keyword instead of the “start” keyword within the same instruction and you will see the synchronization happening.

Now, check for the status of the NTP daemon using the very same command with the update at the word “enable”. Replace it with the “status” keyword.

Try using the ntpdate instruction with the sudo rights and the URL to the Web pool server for the update of your system time and date.

You can install the ntpstat utility of NTP to get the information regarding the statistics happening within the NTP daemon. The installation instruction is displayed in the following image:

The ntpstat instruction can synchronize your daemon with the pooling server out there. To monitor the NTP daemon, try using the ntpq command along with the “-q” option. The following output is presented with its metadata:

Conclusion

This article is all about the use of ntpdate utility utilization in the command shell of Ubuntu 20.04 Linux operating system to update the system’s date and time follow the globally used NTP servers. That’s it! You can learn more by implementing the whole article.

About the author

Omar Farooq

Hello Readers, I am Omar and I have been writing technical articles from last decade. You can check out my writing pieces.