Question: I would like to know the steps to change the default Timezone in Linux. I have CentOS 6.7 installed and the date command displays CST timezone as shown below
$date Tue Dec 19 00:22:20 CST 2015
Can you explain me how to change CST to IST timezone in Linux?
Answer:
In few Linux distributions, the Timezone is controlled by ‘/etc/localtime’.
$ls -l /etc/localtime
Note: /etc/localtime is a binary file, you can’t read it.
Now, go ahead and delete the localtime as shown below:
$rm /etc/localtime
List of Timezones
You can find all timezone related files under ‘/usr/share/zoneinfo’.
$ls -l /usr/share/zoneinfo/ Africa/ CST6CDT GMT Israel NZ-CHAT Singapore America/ Cuba GMT0 Jamaica Pacific/ Turkey Antarctica/ EET GMT-0 Japan Poland UCT Arctic/ Egypt GMT+0 Kwajalein Portugal Universal Asia/ Eire Greenwich Libya posix/ US/ Atlantic/ EST Hongkong MET posixrules UTC Australia/ EST5EDT HST Mexico/ PRC WET Brazil/ Etc/ Iceland MST PST8PDT W-SU Canada/ Europe/ Indian/ MST7MDT right/ zone.tab CET GB Iran Navajo ROC Zulu Chile/ GB-Eire iso3166.tab NZ ROK
Since you want to set IST Timezone, lookout for “Asia” folder under ‘/usr/share/zoneinfo’.
$ls -l /usr/share/zoneinfo/Asia/ Aden Chungking Kabul Novokuznetsk Tashkent Almaty Colombo Kamchatka Novosibirsk Tbilisi Amman Dacca Karachi Omsk Tehran Anadyr Damascus Kashgar Oral Tel_Aviv Aqtau Dhaka Kathmandu Phnom_Penh Thimbu Aqtobe Dili Katmandu Pontianak Thimphu Ashgabat Dubai Khandyga Pyongyang Tokyo Ashkhabad Dushanbe Kolkata Qatar Ujung_Pandang Baghdad Gaza Krasnoyarsk Qyzylorda Ulaanbaatar Bahrain Harbin Kuala_Lumpur Rangoon Ulan_Bator Baku Hebron Kuching Riyadh Urumqi Bangkok Ho_Chi_Minh Kuwait Saigon Ust-Nera Beirut Hong_Kong Macao Sakhalin Vientiane Bishkek Hovd Macau Samarkand Vladivostok Brunei Irkutsk Magadan Seoul Yakutsk Calcutta Istanbul Makassar Shanghai Yekaterinburg Chita Jakarta Manila Singapore Yerevan Choibalsan Jayapura Muscat Srednekolymsk Chongqing Jerusalem Nicosia Taipei
Set Correct zone
Create a symbolic link to corresponding Timezone as shown below:
$ cd etc/
$ ln -s /usr/share/zoneinfo/Asia/Kolkata localtime
$file /etc/localtime /etc/localtime: symbolic link to `/usr/share/zoneinfo/Asia/Kolkata'
$date Tue Dec 29 12:05:04 IST 2015
That’s it!