Changing timezone in Debian and Ubuntu Linux using tzdata

Written by - 0 comments

Published on January 13th 2021 - Listed in Linux


Although UTC is a great way to compare server logs across the globe, analyzing logs with an offset to the (human) local time can be difficult and annoying.

Luckily a server's timezone is quickly adjusted using the tzdata package.

First check the current time interpretation and time zone:

root@linux:~# date
Wed 13 Jan 2021 07:26:11 AM UTC

In this case we can see the time is 07:26:11 and the timezone is set to UTC. That's a one hour off from where I live as Switzerland's winter time is UTC+1 (note: Summer time is UTC+2).

The current timezone can be quickly verified by checking the contents of /etc/timezone:

root@linux:~# cat /etc/timezone
Etc/UTC

Although it would seem easy to simply update the content of that file, that won't be enough for the whole system. Instead the tzdata should be reconfigured using dpkg-reconfigure:

root@linux:~# dpkg-reconfigure tzdata

This command opens up an interactive ncurses window asking to choose the new timezone:

In my case I used the cursors on the keyboard to move up to Europe and then select Zurich at the end:

Selecting new timezone in Debian

After closing the ncurses window with "OK", the following output is shown in the terminal, confirming the timezone change:

Current default time zone: 'Europe/Zurich'
Local time is now:      Wed Jan 13 08:27:24 CET 2021.
Universal Time is now:  Wed Jan 13 07:27:24 UTC 2021.

And the timezone can be verified once again using date and checking the contents of /etc/timezone:

root@linux:~# date
Wed 13 Jan 2021 08:27:34 AM CET

root@linux:~# cat /etc/timezone
Europe/Zurich


Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.