Sometimes we forgot to set timezone properly for newly installed system or sometimes we need to change timezone of systems for various testing etc. Under CentOS/RHEL systems all timezone settings file are located under /usr/share/zoneinfo/ directory and /etc/localtime is the file use is used by operating system to set current timezone for system. So the best way to change time zone of server is to link /etc/localtime file to correct configuration file under /usr/share/zoneinfo/ files.
First check current timezone used by your system using date command.
[[email protected] ~]# date Fri Jan 2 05:10:00
As per above example our system timezone is set to EST.
Change TimeZone in CentOS/RHEL 7
In CentOS/RHEL 7 we use timedatectl command to change current timezone of system. First use following command to list all timezones
# timedatectl list-timezones
Now use following command to change timezone to America/Los_Angeles.
# timedatectl set-timezone
Change TimeZone in CentOS/RHEL 6/5
To change timezone on CentOS/RHEL 6/5 we can simply link /etc/localtime file with correct timezone configuration file. For example we are setting America/Los_Angeles as our local system timezone.
# mv /etc/localtime /root/localtime.old # ln -s
Your timezone has been changed successfully. Lets check timezone again.
[[email protected] ~]# date Fri Jan 2 14:10:54