Changing timezone manually on CentOS / Debian

From lxadm | Linux administration tips, tutorials, HOWTOs and articles
Jump to: navigation, search

Here are some quick notes on how to change the timezone on CentOS, RedHat, Debian, Ubuntu and similar Linux systems.

CentOS / RedHat[edit]

Timezone is set in /etc/localtime file. You have to simply replace it with a different timezone file. Timezone files are stored in /usr/share/zoneinfo/ – example below:

rm -f /etc/localtime; ln -s /usr/share/zoneinfo/Europe/Copenhagen /etc/localtime

There is one more change you have to do: supplying a proper timezone in /etc/sysconfig/clock file. In our case, it would be:

echo 'ZONE="Europe/Copenhagen"' > /etc/sysconfig/clock


Or, to change the timezone to UTC:

rm -f /etc/localtime; ln -s /usr/share/zoneinfo/UTC /etc/localtime
echo 'ZONE="UTC"' > /etc/sysconfig/clock

Debian / Ubuntu[edit]

To change the timezone on Debian / Ubuntu, run the following command:

dpkg-reconfigure tzdata