How to change Time zone in Linux


Method 1: Creating link file to corresponding Timezone

# cd /etc
# rm localtime  //delete the existing localtime file

Check the available time zones in US

# ls /usr/share/zoneinfo/US/    
Alaska          Arizona         Eastern         Hawaii          Michigan        Pacific
Aleutian        Central         East-Indiana    Indiana-Starke  Mountain        Samoa

Note: For other country timezones, browse the /usr/share/zoneinfo directory

Now we can change the time zone using below step

# ln -sf /usr/share/zoneinfo/Asia/Calcutta localtime

Now check the time

#date 

# date
Mon Aug 17 23:10:14 IST 2013

But if you are doing any patching then after patching this Time zone will get changed. So this method is not perfect one.


                                            



Method 2: Change TimeZone Using /etc/timezone File


# vi /etc/timezone
America/Los_Angeles 

then export the TZ variable

$ export TZ=America/Los_Angeles
$ date


Method 3: Command line tools.

Using below interactive method also we can change the Time zone

Ubuntu: dpkg-reconfigure tzdata
Redhat: redhat-config-date
CentOS/Fedora: system-config-date
FreeBSD/Slackware: tzselect



0 comments:

Post a Comment

Blogger Tips and TricksLatest Tips And TricksBlogger Tricks