Changing timezone in Debian and Ubuntu Linux using tzdata

Written by - 0 comments

Published on - 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.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Icingaweb   Icingaweb2   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder   


Update cookies preferences