Changing the timezone on Linux is easy. The timezone within Linux is set by a symbolic link located in the /etc directory which needs to be changed to the new timezone. Once this is changed the time needs to be synced to a time server. I recently moved from Las Vegas to Louisville and had not changed a Linux server to the new timezone. Follow the steps below and the new timezone will be set and updated.
- Backup Current Timezone: Issue the below command on your server to backup the current timezone information just in case there are issues.
cp -p /etc/localtime /etc/localtime.bak
- Select New Timezone: First choose from the list of timezones located in /usr/share/zoneinfo. Below are examples of what the categories of zones followed by the details of what the America directory looks like.
[root@server ~]# ls /usr/share/zoneinfo/ Africa Asia Canada Cuba EST Factory GMT0 Hongkong Iran Japan Mexico Navajo Poland PRC ROK Universal W-SU America Atlantic CET EET EST5EDT GB GMT-0 HST iso3166.tab Kwajalein Mideast NZ Portugal PST8PDT Singapore US zone.tab Antarctica Australia Chile Egypt Etc GB-Eire GMT+0 Iceland Israel Libya MST NZ-CHAT posix right Turkey UTC Zulu Arctic Brazil CST6CDT Eire Europe GMT Greenwich Indian Jamaica MET MST7MDT Pacific posixrules ROC UCT WET [root@server ~]# ls /usr/share/zoneinfo/America/ Adak Barbados Caracas Danmarkshavn Fort_Wayne Havana La_Paz Menominee Nipigon Porto_Velho Sao_Paulo Thule Anchorage Belem Catamarca Dawson Glace_Bay Hermosillo Lima Merida Nome Puerto_Rico Scoresbysund Thunder_Bay Anguilla Belize Cayenne Dawson_Creek Godthab Indiana Los_Angeles Mexico_City Noronha Rainy_River Shiprock Tijuana Antigua Blanc-Sablon Cayman Denver Goose_Bay Indianapolis Louisville Miquelon North_Dakota Rankin_Inlet St_Barthelemy Toronto Araguaina Boa_Vista Chicago Detroit Grand_Turk Inuvik Maceio Moncton Panama Recife St_Johns Tortola Argentina Bogota Chihuahua Dominica Grenada Iqaluit Managua Monterrey Pangnirtung Regina St_Kitts Vancouver Aruba Boise Coral_Harbour Edmonton Guadeloupe Jamaica Manaus Montevideo Paramaribo Resolute St_Lucia Virgin Asuncion Buenos_Aires Cordoba Eirunepe Guatemala Jujuy Marigot Montreal Phoenix Rio_Branco St_Thomas Whitehorse Atikokan Cambridge_Bay Costa_Rica El_Salvador Guayaquil Juneau Martinique Montserrat Port-au-Prince Rosario St_Vincent Winnipeg Atka Campo_Grande Cuiaba EnsenadaGuyana Kentucky Mazatlan Nassau Porto_Acre Santiago Swift_Current Yakutat Bahia Cancun Curacao Fortaleza Halifax Knox_IN Mendoza New_York Port_of_Spain Santo_Domingo Tegucigalpa Yellowknife
- Link New Timezone: Now use the below command to link /etc/localtime to the proper timezone. In the example used we link the Louisville timezone from America which is EST.
ln -sf /usr/share/zoneinfo/America/Louisville /etc/localtime
- Set Time from Time Server: This command will set the time on your server according to UTC offset by the timezone you have chosen.
rdate -s cuckoo.nevada.edu
- Verify New Time: Now issue the below command to verify the new time has been accepted.
[root@server ~]# date Mon Jan 20 05:19:04 EST 2009
That is all you have to do. The new timezone will be used from now on when the server reboots and when you update the time on the server using rdate.Tags: /etc, date, est, Linux, ln, localtime, pst, rdate, symbolic, time, timezone, zoneinfo