Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to reset the timezone through editing /etc/timezone. However, after I was done editing and saved the file, the system time did not change accordingly.

On the other hand, when I take advantage of the command dpkg-reconfigure tzdata to change the timezone, the time will change immediately. Plus, the /etc/timezone file is modified accordingly.

What steps am I missing after editing and saving the config file in order for the new time to take effect?

share|improve this question
up vote 3 down vote accepted

Take a look at /var/lib/dpkg/info/tzdata.postinst, which I think is what is being run when dpkg-reconfigure tzdata is called.

Note in particular the following command, which runs after /etc/timezone has been updated.

cp -f /usr/share/zoneinfo/$AREA/$ZONE /etc/localtime.dpkg-new && \
            mv -f /etc/localtime.dpkg-new /etc/localtime

So, the file /etc/localtime needs to be updated. I haven't tried it, but my guess is that is an important step in making the timezone change. It is unclear if the tzdata maintainer expects you to make this change manually if you have edited /etc/timezone yourself.

share|improve this answer

Since you've found that dpkg-reconfigure tzdata works, why don't you use it?

If the problem is that it's interactive and you want to script the change, it's possible. The timezone is configured through debconf. You can set values with debconf-set-selections. Then reconfigure the package, telling it not to prompt for anything.

debconf-set-selections <<EOF
tzdata tzdata/Areas select Europe
tzdata tzdata/Areas seen true
tzdata tzdata/Zones/Europe select Paris
tzdata tzdata/Zones/Europe seen true
dpkg-reconfigure -fnoninteractive tzdata

Applications read /etc/localtime when they first need the time zone information. This is performed by the system's standard library, so you won't find many exceptions if at all. /etc/localtime is usually a symbolic link to a file under /usr/share/zoneinfo, or a copy of such a file. Most applications need to be restarted for a change of this file to take effect.

The file /etc/timezone contains the name of a time zone. Normally /etc/localtime is a link to or copy of /usr/share/zoneinfo/$(cat /etc/timezone). /etc/timezone is used by the packaging system mainly (only?), which explains why changing it didn't have any visible effect.

Remember that you can use a different timezone in a particular application by starting it with the TZ environment variable, e.g. TZ=Pacific/Tarawa date.

share|improve this answer
there is a simpler way. see unix.stackexchange.com/a/215354/120177 – Evgeny Vereshchagin Jul 12 '15 at 18:13

You might be able to run service timezone restart to make this take effect manually. This does for just about any system config file. Whatever service depends on those configs will need to be restarted after a file is changed.

Changing the file /etc/timezone is actually be sufficient, but you would normally need to reboot or at least login again for it to take affect. Changing the time zone isn't something system makers anticipated happening enough to make it a frequently re-read config file!

In some cases, you will also need to login again because of environment variables that get set when you first login. For example the system language variable is often set on login and changing the config file will not affect users that are already logged in.

share|improve this answer
It does not seem to work even after rebooting. – Terry Li Jul 6 '11 at 20:26
And running service timezone restart gave me timezone: unrecognized service error. – Terry Li Jul 6 '11 at 20:29

So, something like:

set $area="America"
set $zone="Los_Angeles"
sudo echo "$area/$zone" > /tmp/timezone
sudo cp -f /tmp/timezone /etc/timezone
sudo cp -f /usr/share/zoneinfo/$area/$zone /etc/localtime
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.