How to set timezone in linux – Ubuntu Hardy

Posted by Prem on January 12th, 2010 filed in Linux

Now with the proliferation of Cloud computing, we often come across the necessity to configure the linux server to run in a particular timezone other than where it is running.  I had to do this in some of our servers, so I thought, I would share this information with others.

The server’s current timezone is defined by the file /etc/timezone.  The timezone files for other zones are located in the folder /usr/share/zoneinfo.

First save your current timezone file.  Rename this file as a backup.  You can also delete the same.

mv /etc/timezone /etc/timezone.backup

Now lets take a look at the collection of timezone files.

cd /usr/share/zoneinfo

Take a look at the files.  Each file pertains to a particular timezone.  The filename’s are quite explanatory.  For countries with multiple timezone, like US, Canada etc,   you will see a folder named by the country.  Inside this folder you will see these files.  Choose the timezone file you want to use.  For eg.  lets say, I want to set the timezone to US – PST.  The timezone file for this is /usr/share/zoneinfo/US/Pacific

Just run,

cp /usr/share/zoneinfo/US/Pacific /etc/timezone

All set.  Run the date command to see the server’s timezone is now set to PST.

Have fun.

Leave a Comment

You must be logged in to post a comment.