How to change the time zone in Ubuntu using the command line

The time zone configuration is part of the tzdata package. There are multiple ways to change the time zone using the command line.


To interactively change the time zone open a terminal and run following command:

sudo dpkg-reconfigure tzdata 

Follow the directions in the terminal by selecting the geographic area and then the city or region corresponding to your time zone.


First find out the name for the time zone you want to configure. The name is usually in the form <area>/<city> where area is a continent or ocean and city is a big city in that area (e.g. Europe/Berlin for Germany).

To update the time zone in Ubuntu 16.04 and newer non-interactively, change the symlink in /etc/localtime to point to the time zone in /usr/share/zoneinfo and then reconfigure tzdata. Example for Europe/Berlin:

sudo ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime
sudo dpkg-reconfigure -fnoninteractive tzdata

Configure before installing tzdata

If tzdata is not installed yet, feed debconf with values for tzdata keys and install tzdata afterwards. Example for Europe/Berlin:

printf "tzdata tzdata/Areas select Europe\ntzdata tzdata/Zones/Europe select Berlin\n" | sudo debconf-set-selections
DEBIAN_FRONTEND=noninteractive sudo apt-get install tzdata
1 Like