How to Synchronize Time with NTP in Linux

The Network Time Protocol (NTP) is a protocol used to synchronize computer system clock automatically over a networks. The machine can have the system clock use Coordinated Universal Time (UTC) rather than local time.

The most common method to sync system time over a network in Linux desktops or servers is by executing the ntpdate command which can set your system time from an NTP time server. In this case, the ntpd daemon must be stopped on the machine where the ntpdate command is issued.

In most Linux systems, the ntpdate command is not installed by default. To install it, execute the below command.

$ sudo apt-get install ntpdate    [On Debian/Ubuntu]
$ sudo yum  install ntpdate       [On CentOS/RHEL]
$ sudo dnf install ntpdate        [On Fedora 22+]

The example of ntpdate command as shown.

$ sudo ntpdate
Check Date and Time in Linux

Check Date and Time in Linux

In order to just query the server and not set the clock and use an unprivileged port to send the packets from, in order to bypass firewalls, issue ntpdate with the below flags.

$ sudo ntpdate -qu
Query NTP Server

Query NTP Server

Always try to query and sync the time with the closest NTP servers available for your zone. The list of the NTP server pools can be found at the following address: 

In newer Linux distributions that ship with Systemd, you can also sync time via timesyncd.conf file. Just open the file for editing.

$ sudo nano /etc/systemd/timesyncd.conf

And add or uncomment the following lines after [Time] statement, as illustrated in the below excerpt:

Sync Linux Time with NTP Server

Sync Linux Time with NTP Server

After editing the file, issue the timedatectl command to activate the NTP client build in systemd.

$ sudo timedatectl set-ntp true 
$ timedatectl status
Check Linux System Time

Check Linux System Time

Afterwards, issue date command in order to display your system clock.

Best Affordable Linux and WordPress Services For Your Business
Outsource Your Linux and WordPress Project and Get it Promptly Completed Remotely and Delivered Online.

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Matei Cezar

I'am a computer addicted guy, a fan of open source and linux based system software, have about 4 years experience with Linux distributions desktop, servers and bash scripting.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

3 Responses

  1. Hal Baird says:

    I have a dual boot W10/Ubuntu PC. When I boot to Ubuntu from W10, the displayed time is correct before the Ubuntu home page comes up, then decreases by 4 hours when the Ubuntu home page is displayed.

    When booting back to W10, the time stays in error by 4 hours.

    How do I get correct time without having to synchronize after every boot ?

  2. Matei Cezar says:

    Use ntpdate on machine where you don’t want to run a NTP server. A simple Cron task can automate time synchronization with a upstream NTP server.

  3. David says:

    According to a post at ntpdate has been deprecated since 2012. The current tools are ntpd and chrony.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.