Ubuntu – How to make an Ubuntu time zone change stick

configurationtimezoneUbuntu

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?

Best Answer

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.

Related Question