The ntpdate command in Linux is used to synchronize the local date of your machine by connecting to an NTP server. If your machine does not have a connection to the Internet, the Network Time Protocol (NTP) is the option you have to set up the correct time, which doesn’t require an Internet connection.
However, this service does not come pre-installed in most Linux distributions, which means that if you get the error “ntpdate: command not found”, it probably means that you don’t have the ntpdate command not installed in your machine. Now here’s one thing to note. If you’re using Arch Linux, trying to search directly for their ntpdate package won’t work, and you won’t find any. This is because the ntpdate command does not have an installation candidate for itself.
Install the ntpdate command
Install ntpdate in Arch Linux
Now hear me out very close. In most other places where you look out for a fix, you’ll see that under Arch Linux, they’d tell you to install the ntpdate package. Unfortunately, if you try it out, you’d get an error because no such package exists in the Arch Linux’s repository.
So how do you get the ntpdate command then? Don’t worry, because rather than having a package for itself, it comes shipped along with another different package, which is ntp. Ntp is a command that can be executed itself, but if you install this package, you can also use the regular ntpdate command. To install this package, execute the following command in your Linux terminal, if you’re using Arch Linux:
$ sudo pacman -Syu ntp
To try out whether the command works, simply type out ntpdate in the terminal and execute it:
If you get an output like the one shown above, then it means that you;ve successfully installed the command, and can now execute it without any further issues.
Install ntpdate in other linux Distros
In most other distributions other than Arch Linux, the package for ntpdate is its name itself, so it shouldn’t be much of a hassle. If your system’s repository does not have the package, you can try installing it from source code, which will be discussed further in the next section.
For now, here are some of the commands you’d commonly use in popular Linux distributions to install the ntpdate command:
$ sudo apt-get install ntpdate
$ sudo apt-get install ntpdate
$ sudo yum install ntpdate
$ sudo dnf install ntpdate
This should pretty much fix your issue with the error message of being unable to find the ntpdate command, in your Linux machine. Try it out by executing the ntpdate command inside the terminal.
Install ntpdate from source code
It is possible that your specific system does not have the ntpdate package. In this case, you can install the ntpdate command from the source code.
First, download the .tar.gz archive from the official ntp website, ntp.org.
Now enter your terminal, and navigate to the directory where the downloaded file is located using the cd command. Once you entered the directory, extract the archived package by using the following command:
$ tar -xf ntp-4.2.8p15.tar.gz
Make sure to replace the package’s name with the actual one that you yourself have installed. Now enter the extracted directory by using:
$ cd ntp-4.2.8p15/
Inside this folder, run the configure script to prepare the source code for compilation, by running:
Then run make to compile the package:
Lastly, run the following command to make the program available system wide so that you can execute it from any directory:
$ sudo make install
If you haven’t encountered any error messages, then you’ve successfully installed the package. Now try running the ntpdate command to see if everything works fine.
However, during my testing, I faced some error messages when running make. It is probably something related to the constant changes in code libraries and everything. But it shouldn’t be the same for your case as well. If you still face the error yourself, it’s best you look out for some alternatives, if there’s no other source for you left to install it.
Also, if you have chosen to install it in some other directory than /usr/bin, which is the default path for such programs, you need to include that path in the Global PATH variable of your system, so that bourne again shell can trace it while startup. Otherwise, you’ll not be able to run it from any other directory than the one where you installed.
To do this, you need to add the following line in the .bashrc file which should be located in your home directory, hidden:
Replace /path/to/installation/directory with the actual path where you have installed the command. Moreover, if you’re using some other shell than bourne again shell, than adding it to .bashrc will not work. Instead, you’ll have to add in in the configuration file for that specific shell. So make sure you don’t mess it up!
sntp – A simple alternative to ntp
SNTP is a simplified version of the Network Time Protocol (NTP), just as its name suggests, which is “Simple Network Time Protocol”. It can be considered as a lighter version of NTP, where the actual difference between the two lies in their method of checking errors and correcting the time. NTP is far more accurate than SNTP, but is a bit tougher to get into. As compared, SNTP is easier to use, yet it does the job well as long as you’re not worried about harnessing sheer accuracy. However, despite the utility being easy itself, the installation procedure of SNTP will not be as simple as you expect. Why not try searching for it in google?
I’m quite hopeful that you’ve successfully been able to surpass the issue yourself, and are now able to execute the ntpdate command. The ntpdate command is a bit tricky, not actually in terms of its use, but to figure out why you may need to use it as compared to the ntp command itself. The main difference is that, using the ntp command will start the nptd daemon on your machine, which will allow the service to run on the background and sync the time and date from there. Whereas, using the ntpdate command will get you the correct date and time for once only, during its execution.