Debian Linux: Setting the timezone and synchronizing time with NTP

Debian LogoI have previously written about setting the time and timezone in CentOS. Setting the timezone is much easier in Debian.

Setting the timezone

First take a look at your current time and date by running:

date

It should display something like this:

Sat Feb  9 03:00:29 PKT 2013

To change the timezone just run the following as root and you’ll be able to pick out your timezone from a list:

dpkg-reconfigure tzdata
Timezone reconfigure on Debian

Set timezone on Debian

Synchronizing time with an NTP server

Network Time Protocol is a standard for synchronizing time across computer networks. You can use it to synchronize your computer’s time with exceptionally accurate time keeping devices like atomic clocks.

To synchronize time with an NTP server you have to install ntpdate:

apt-get install ntpdate

And then just run it like so:

ntpdate us.pool.ntp.org

There are a number of NTP servers around the world. You can find a full list on ntp.org.

To make the changes stick you need to set the hardware clock on your system too:

hwclock --systohc

ntp daemon

To ensure that your server’s clock is always accurate you can install the ntp daemon:

apt-get install ntp

That’s all you have to do! By default the ntp service is run after installation and also set to run at boot up.

3 thoughts on “Debian Linux: Setting the timezone and synchronizing time with NTP

    • This is what I get in wheezy when I run tzconfig:

      WARNING: the tzconfig command is deprecated, please use:
      dpkg-reconfigure tzdata

Leave a Reply

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