Tel Map

Blog

Changing the Timezone in Debian 9 (Stretch)

Since the release of the newest Debian version 9 (Codename “Stretch”) in June 2017, most system administrators using this distribution will upgrade their systems eventually. One of the changes in the new version that first caught my eye, is that you can’t configure the system’s time zone in the way that most Debian tutorials suggest.
While you might consider this to be a minor issue, I believe that a wrongly configured time zone will lead to confusion in log files and web applications.

How older Tutorials suggest to change the time zone

While this has worked in older Debian version, it will not be enough in Stretch, because not the configured /etc/timezone  is used, but also the Symlink /etc/localtime . To make matters worse, the configured  /etc/timezone will be overwritten by the old value after executing dpkg-reconfigure .

How to change the timezone in Debian Stretch

The first command will create a new symlink from the correct time zone data (located inside /usr/share/zoneinfo ) to /etc/localtime , and the the reconfiguration of the tzdata package will adjust the system accordingly, setting the /etc/timezone  file automatically.

7 Replies to “Changing the Timezone in Debian 9 (Stretch)”

  1. Mario B.

    Danke, das hat mit einige Zeit des Suchens erspart. Man bekommt langsam Angst vor jedem Update, jedesmal eine neue Kleinigkeit die nicht geht.

  2. Danke schön. Da kann ich mich meinem Vorschreiber (Mario B.) anschließen. Hat einiges an Suche erspart. Sonst wurde kontinuierlich die kanadische Zeit angezeigt (AV Linux mit Debian 9.8 und XFCE 4 Oberfläche.)

  3. Lenny

    With stretch and newer, you can instead do

    echo “Europe/Berlin” > /etc/timezone
    rm -f /etc/localtime
    dpkg-reconfigure -f noninteractive tzdata

    The reconfigure step will then recreate the localtime symlink to the correct location

    1. Christian Simon Post author

      Yes, it seems you are right! Thanks for the tip.

      I believe the important part is, that there is no /etc/localtime present that disagrees with the /etc/timezone setting.

Leave a Reply

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