Changing timezone in CentOS/Redhat 7 is now different from the previous CentOS/Redhat versions.
This howto shows how to change the timezone in CentOS/RedHat 7 and previous versions.



Change TimeZone in CentOS/RedHat 7

List all available timezones

To find list of all available time zones, run:

[[email protected] yum]$ timedatectl list-timezones

A portion of the sample output is as shown below:

[[email protected] yum]$ timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
Africa/Blantyre
Africa/Brazzaville
Africa/Bujumbura
Africa/Cairo
Africa/Casablanca
Africa/Ceuta
Africa/Conakry
Africa/Dakar

Set the timezone

Now that we know what the names of the timezones are, we can now set the timezone. For example from the above command we want to set timezone to Europe/Madrid:

[[email protected] yum]# timedatectl set-timezone Europe/Madrid
The timedatectl command simply really just updates the symlink /etc/localtime as shown below.
[[email protected] ]# ls -al /etc/localtime
lrwxrwxrwx. 1 root root 35 May  1  2016 /etc/localtime -> ../usr/share/zoneinfo/Europe/Madrid

Change or Set timezone in CentOS/RedHat 6.x

Unlike in the latest CentOS/RedHat we do not have a timedatectl command. Instead we simply have an /etc/localtime symlink to a file in /usr/share/zoneinfo. So to change timezone , you must first find the timezone file in /usr/share/zoneinfo.

Find the timezone file

The following example gives you an idea of how to find the timezone file:

[email protected] yum]# cd /usr/share/zoneinfo/
[[email protected] zoneinfo]# ls
Africa      Arctic    Australia  CST6CDT  Cuba  EST5EDT  Etc     GB-Eire  GMT-0      HST       Indian  Jamaica    Libya  MST7MDT  NZ-CHAT  PST8PDT  Portugal  Singapore  US         W-SU  iso3166.tab  right America     Asia      Brazil     Canada   EET   Egypt    Europe  GMT      GMT0       Hongkong  Iran    Japan      MET    Mexico   Navajo   Pacific  ROC       Turkey     UTC        WET   posix        zone.tab Antarctica  Atlantic  CET        Chile    EST   Eire     GB      GMT+0    Greenwich  Iceland   Israel  Kwajalein  MST    NZ       PRC      Poland   ROK       UCT        Universal  Zulu  posixrules
[[email protected] zoneinfo]#
Note that /usr/share/zoneinfo as shown above also have subdirectories. So if you do not recognise a usable timezone file, dig down into the directories. For example, the file /usr/share/zoneinfo/America/New_York represents time zone for New York.

Symlink /etc/localtime to the timezone file.

For example lets say we have decided we want to share our server to America/New_York and the timezone file is /usr/share/zoneinfo/America/New_York.

So first remove the /etc/timezone

[email protected] yum]# rm /etc/localtime

Follow that with creating the symlink:

[email protected] yum]# ln -s /usr/share/zoneinfo/America/New_York /etc/localtime