Changing Timezone in Linux

Sarath Pillai's picture
changing time zone in linux

When you work in a desktop graphical user interface environment, most of the of the popular linux distributions these provide with a nice interface to change timezones and time format etc.

But when you work on a server or a console installation of any distribution, changing timezone can be tricky. All machines work with two clocks, one is the hardware clock and the other is called as operating system clock.

Hardware clock: this clock keeps maintains its time with the help of a battery inside the computer which is sometimes called cmos battery. this battery ensures that the hardware clock will work, even if the computer itself is turned off. Whenever an operating system boots,it sets its own clock, by referring to hardware clock.

The zone settings in linux is handled by adding a symbolic link to the localtime file located in /etc

for example suppose imagine you have your timezone set as IST(Asia/calcutta) then you will see a symbolic link to the zone calcutta file for /etc/localtime.

Now there is a directory in linux /etc/zoneinfo where all timezone based information is saved, this directory contains all files used for different timezones.

Now if suppose you want to change your timezone to whatever you like, you need to find the corresponding file in the /usr/share/zoneinfo directory.

Lets take an example where we require to change our timezone to UTC, coz most of the servers time are always configured to be UTC.

Now to change time zone to UTC in redhat, you need to do an additional step, by making "UTC=true"in /etc/sysconfig/clock

Now as mentioned before, there will be a corresponding file for every timezone in /usr/share/zoneinfo, and for UTC we have the file /usr/share/zoneinfo/UTC

Now we just have to give that UTC zoneinfo file a soft link to /etc/localtime, as shown below.

ln -sf /usr/share/zoneinfo/UTC /etc/localtime

Note: For all regional specific timezones, you need to find that exact corresponding timezone file in /usr/share/zoneinfo/

Thank you all...Hope this post was helpful!

Rate this article: 
Average: 3.8 (33 votes)

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.