8

Is there a way i can set the current timezone via the commandline/terminal? Its for a shelle script so im looking for some, hopefully, one liner like date -Z 'Europe/London' (Just an example), in other words just a command to write and not anyhting todo with graphics

Is there any built in way of doing it ?

2 Answers 2

6

This works on Linux Mint, Ubuntu, Debian, I think most Debian-based distros...

echo "America/Eastern" | sudo tee /etc/timezone
sudo dpkg-reconfigure --frontend noninteractive tzdata

Where to find timezones:

Or (as commented) use timedatectl list-timezones to find a zone, then timedatectl set-timezone [timezone]


If required, see this Debian page about Time Zone Changes. You could use the program zic along with changing some files, if you wanted to change the details of the time zone, like daylight savings time start & end dates, etc.

1
  • This didn't work for me. I tried with Europe/Berlin but dpkg-reconfigure always sets /etc/timezone back to Etc/UTC. I have to link the zoneinfo file manually as shown in the answer by SystemCookie. Mar 26, 2020 at 10:35
4

You can change it with more than one line. Exactly two lines.

  1. mv /etc/localtime /etc/localtime.old

and then Link your TimeZone file like this:

  1. ln -s /usr/share/zoneinfo/Europa/London /etc/localtime

You can check with date

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .