How to change timezone and synchronize time in Debian Linux

To ensure that things are being logged with correct time stamps in your system logs, it is important that your system is configured for your particular timezone and that your system clock is being synchronized to a correct time source. Normally when you set up your Debian Linux system the correct time zone will be choosen. If the time zone is set wrong for some reason it needs to be adjusted.

To check your current time zone issue the command:

# date
Wed Jul 15 11:05:15 UTC 2009

In this example the system is set to the UTC time zone which in my case is incorrect. To set the correct time zone the command tzconfig can be used:

# tzconfig
Your current time zone is set to Unknown
Do you want to change that? [n]: y

Please enter the number of the geographic area in which you live:

        1) Africa                       7) Australia

        2) America                      8) Europe

        3) US time zones                9) Indian Ocean

        4) Canada time zones            10) Pacific Ocean

        5) Asia                         11) Use System V style time zones

        6) Atlantic Ocean               12) None of the above

Then you will be shown a list of cities which represent the time zone
in which they are located. You should choose a city in your time zone.

Number: 8

Amsterdam Andorra Athens Belfast Belgrade Berlin Bratislava Brussels
Bucharest Budapest Chisinau Copenhagen Dublin Gibraltar Guernsey Helsinki
Isle_of_Man Istanbul Jersey Kaliningrad Kiev Lisbon Ljubljana London
Luxembourg Madrid Malta Mariehamn Minsk Monaco Moscow Nicosia Oslo Paris
Podgorica Prague Riga Rome Samara San_Marino Sarajevo Simferopol Skopje
Sofia Stockholm Tallinn Tirane Tiraspol Uzhgorod Vaduz Vatican Vienna
Vilnius Volgograd Warsaw Zagreb Zaporozhye Zurich

Please enter the name of one of these cities or zones
You just need to type enough letters to resolve ambiguities
Press Enter to view all of them again
Name: [] Stockholm
Your default time zone is set to 'Europe/Stockholm'.
Local time is now:      Wed Jul 15 13:06:51 CEST 2009.
Universal Time is now:  Wed Jul 15 11:06:51 UTC 2009.

The time zone is now changed to CEST.

Now it is a good idea to install the ntp package in order to synchronize the system clock to a reliable time source. To install ntp issue the following command:

# aptitude install ntp

Done. Note that if you are running a vserver ntp should not be installed in the client but in the host.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

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

2 × five =