Friday, June 1

How to Change Time Zone in Linux RHEL/CentOS 6&7


Time Zone change is required Some times  when we move our Machines(VMs) from one location to another location.
You can easily change timezone in RHEL/CentOS using the following methods.
Check which time zone you are in by using date command.

Example:
[root@bsrtech ~]# date
Fri Jun  1 12:26:53 IST 2018

Actually My Machine(VM) is moved from India to US(Eastern Time)  Data Centre. Here i am showing change time zone from IST to EDT.

In Linux timezone data is taken from /etc/localtime which is linked to one of the file located in /usr/share/zoneinfo/*
Delete the current localtime file under /etc/ directory, before deleting backup the localtime file

[root@bsrtech ~]# cd /etc
[root@bsrtech ~]# cp /etc/localtime /etc/localtime_bkp_8MAR2018
[root@bsrtech ~]# rm localtime

All US timezones are located under the /usr/share/zoneinfo/US directory as shown below.

[root@bsrtech US]# ls
Alaska    Arizona  Eastern       Hawaii          Michigan  Pacific      Samoa
Aleutian  Central  East-Indiana  Indiana-Starke  Mountain  Pacific-New




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

Link the Eastern file from the above US directory to the /etc/localtime directory as shown below.

[root@bsrtech US]# # ln -s /usr/share/zoneinfo/US/Eastern   /etc/localtime

Now the timezone on your Linux system is changed to US Eastern time as shown below.

[root@bsrtech ~]# date
Fri Jun  1 03:19:21 EDT 2018

Note: The date command can be used for both viewing and changing the date and time. Change the Time using date Command

Set Manual Time
[root@bsrtech ~]# date -s "01 JUNE 2018 02:34:00"
FRI June  1 02:34:00 EDT 2018

:: Linux - Legends ::