Installing and Configuring NTP on Linux

Jack Wallen
Mar 16, 2009
Updated • Dec 28, 2012

NTP is the Network Time Protocol. This protocol allows servers (or desktops) to communicate to very reliable sources to keep their time synchronized. There are two reasons why you would want to employ NTP: 1) You're a geek and you want your time to be perfect. 2) You need your servers all synchronized with the correct time.

Naturally the second reason is far more important than the first. But either way, you might very well be driven to keep your machine on the exact time. To that end you can either constantly monitor the time on your machine (manually changing it when necessary) or you can set up NTP to handle your time corrections for you.

Installing and configuring NTP is actually quite easy. It will, however, require the use of the command line. With that in mind, lets' get busy.


You could open up your Add/Remove Software utility, do a search for "ntp" (no quotes) and install the matching results. Or you can open up a terminal window and install ntp with one of the following commands (remember, you will need either root access or sudo):

  • apt-get install ntp
  • yum install ntp
  • urpmi ntp

One of the above commands will install the ntp daemon and the configuration file /etc/ntp.conf.

Before you fire up the daemon you will need to take a look at the /etc/ntp.conf to make sure you have the ntp servers you want to use configured.


Most likely your NTP installation will already have a configuration file that is ready to go. My Debian-based NTP install had such a .conf file. All I had to do was start the daemon. But you might have special needs or your install might not have been as complete.

The section of the ntp.conf that you will want to take a look at is the server section. Each line in this section is set up like so:


Where IP_ADDRESS is the actual address of the server you want to use and OPTION(S) is/are the option(s) you want to use.

There are two options that you might want to use for every server. These are:

iburst: This option is used when the configured server is unreachable. When your machine can not contact its NTP server it will send out bursts of eight packets (instead of just one).

dynamic: This option allows a server to be configured even if the server is not reachable during configuration. This option assumes that at some point the server will be reachable.

If you look at my /etc/ntp.conf file you will see the following in the server section:

server iburst dynamic
server iburst dynamic
server iburst dynamic
server iburst dynamic

If you are not sure what servers to use visit the official NTP organization to find a list of trusted servers.

Starting the Daemon

Once you have everything up and running go back to the root terminal and issue the command:

/etc/init.d/ntp start


/etc/rc.d/init.d/ntp start

which will start the ntp daemon. NTP will now slowly start to adjust the time on your server. But don't worry, it makes the adjustment slowly. First the daemon waits for at least ten packets of information before trusting a source.

Now test to make sure your installation is working by issuing the following command:

ntpq -p

which should give you a listing like:
remote refid st t when poll reach delay offset jitter =========================================================
+point2.adamants 2 u 44 64 377 75.955 -7.045 2.992
*station.mars.or 2 u 10 64 377 75.477 -1.144 0.977
-www.broadbandja 3 u 56 64 377 72.764 3.766 0.977 2 u 25 64 377 65.686 -7.753 2.539

If you see zeros for the values you know ntp is not connecting. As you can see above my setup is connecting.

Final thoughts

NTP is an easy way to ensure your servers or your desktop is always using the correct time. In mission-critical machines, this can be quite important. Employing NTP will give you the security of knowing your machine's right "on time".


Previous Post: «
Next Post: «


  1. felipe prado said on September 14, 2012 at 5:48 am

    this works perfectly.

  2. Bikash Gyawali said on February 5, 2012 at 5:44 pm

    After issuing the command /etc/init.d/ntp start does the ntp server keep running even after the restart? If not, how to make the service run at startup automatically?

    1. LHelms said on January 24, 2014 at 3:07 am

      To Insure that ntpd starts AFTER a reboot:

      $ chkconfig –add ntpd
      $ chkconfig ntpd on

      You can verify whether it will or not with:

      $ find /etc/rc*.d -name ‘*ntp*’

  3. Peter said on April 1, 2011 at 11:47 am


    I am a newbie on linux. I am trying to fix this for 4 days but still unable to sync with the Internet time server.
    I am trying to do synchronize to the internet time server using my internal server (running on redhat) but it does not work at all.
    After configuring the ntp.conf, i stop the ntpd and start again and still did not work. i able to update the Internet time server using ntpdate commad.

    Please comment on my configuration and show me show direction. :(

    [root@app3 ~]# ntpq -p
    remote refid st t when poll reach delay offset jitter
    LOCAL(0) .LOCL. 10 l 8 64 1 0.000 0.000 0.001

    [root@app3 ~]# /etc/init.d/ntpd stop
    Shutting down ntpd: [ OK ]

    Configuration file:

    Running on:
    [root@app3 /]# /bin/bash –version
    GNU bash, version 3.2.25(1)-release (i686-redhat-linux-gnu)
    Copyright (C) 2005 Free Software Foundation, Inc.

    I am able to update using ntpdate:
    [root@app3 /]# ntpdate
    1 Apr 16:42:22 ntpdate[4812]: adjust time server offset 0.036360 sec

    Configuration file on /etc/ntp.conf

    restrict default ignore

    #allow synchronization sources from the internet servers
    restrict server mask nomodify notrap noquery
    restrict server mask nomodify notrap noquery
    restrict server mask nomodify notrap noquery

    #allow our internal server to synch to this server
    restrict mask nomodify notrap noquery notrust

    server #local system clock
    fudge stratum 10
    driftfile /etc/ntp/drift
    logfile /var/log/ntp.log

  4. Paul(us). said on March 17, 2009 at 1:37 pm

    I realy liking this, christal clear, Jack explenation.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.