• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

CentOS / RHEL 5,6 : How to Change the timezone

By admin

Timezone configuration on Linux is usually set up at installation time. On RHEL 5 and 6, the procedure to change the Timezone configuration is as follows. The example used here is from timezone MDT to IST. The timezone can be either changed from command line or using the system-config-date command.

Using system-config-date command

Use the system-config-date graphical utility:

# system-config-date

In case the command is not available, install the required package with yum :

# yum install system-config-date

Use the system-config-date graphical tool to set the required timezone from a list of timezones as shown below.

RHEL 6 change timezone.

Using the command line

1. Check the file /etc/sysconfig/clock and the date command output to confirm the current timezone set.

# cat /etc/sysconfig/clock
ZONE="America/Denver"
# date
Wed May 17 13:41:16 MDT 2017

2. Navigate to the directory /usr/share/zoneinfo and check the available files. (Each file represents a timezone). Find the file representing the timezone to be configured.

# cd /usr/share/zoneinfo
[root@VOM-VCS-MONITOR zoneinfo]# ls -l
total 296
drwxr-xr-x.  2 root root  4096 Aug 15  2014 Africa
drwxr-xr-x.  6 root root  4096 Aug 15  2014 America
drwxr-xr-x.  2 root root  4096 Aug 15  2014 Antarctica
drwxr-xr-x.  2 root root  4096 Aug 15  2014 Arctic
drwxr-xr-x.  2 root root  4096 Aug 15  2014 Asia
drwxr-xr-x.  2 root root  4096 Aug 15  2014 Atlantic
drwxr-xr-x.  2 root root  4096 Aug 15  2014 Australia
drwxr-xr-x.  2 root root  4096 Aug 15  2014 Brazil
drwxr-xr-x.  2 root root  4096 Aug 15  2014 Canada
......

3. Replace the value on /etc/sysconfig/clock with the path to that file starting from /usr/share/zoneinfo. For example, if the target timezone is IST time for India. The file under /usr/share/zoneinfo representing that timezone is:

/etc/share/zoneinfo/Asia/Kolkata

Therefore, change /etc/sysconfig/clock file so it reads:

ZONE="Asia/Kolkata"

4. Replace /etc/localtime with the appropriate zone file by reading /etc/sysconfig/clock using this command:

# tzdata-update
Replacing /etc/localtime with symlinks to a zone file in RHEL 5 and RHEL 6 is Unsupported.

Verify

You can verify the change of timezone by “date” command and checking the /etc/sysconfig/clock file as shown below.

# cat /etc/sysconfig/clock
ZONE="Asia/Kolkata"
# date
Wed May 17 15:30:22 IST 2017

CentOS / RHEL : Using yum to download a package without installing it

Configuring a different timezone for individual users

To configure a different time zone from the system-wide default for an individual user, add the following line to the .bashrc in that user’s home directory:

export TZ="/usr/share/zoneinfo/[timezone_directory]/[timezone_file]"

In the above directive, replace [timezone_directory] with a time zone directory in the /usr/share/zoneinfo/ directory, such as US, and replace [timezone_file] with a time zone file within that time zone directory, such as Eastern. It is possible to reference any file within the /usr/share/zoneinfo/ directory for valid values.

CentOS / RHEL 7 : How to Change Timezone

Filed Under: Linux

Some more articles you might also be interested in …

  1. Extend the size of /boot partition on virtualized environment (CentOS/RHEL 6)
  2. CentOS / RHEL : How to remove used Physical Volume(PV) from Volume Group (VG) in LVM
  3. How to Enable X11 Forwarding on CentOS/RHEL 5,6,7
  4. What are DNS Nameserver Types in Linux
  5. How to gzip all or specific files in Linux
  6. LVM Configuration : Logical Volume (LV) Operations/Utilities
  7. How to Delete Duplicate Rules in Routing Policy Database in CentOS/RHEL
  8. chattr Command Examples to Change File Attributes (Make files immutable)
  9. RHEL 7 – RHCSA Notes : Create hard and soft links.
  10. “kernel: INFO: task {PROCESS}:{PID} blocked for more than 120 seconds.” – CentOS/RHEL Troubleshooting

You May Also Like

Primary Sidebar

Recent Posts

  • How to disable ACPI in CentOS/RHEL 7
  • How to Use real-time query to access data on a physical standby database
  • CentOS/RHEL 8: “ACPI MEMORY OR I/O RESET_REG” Server Hung after reboot
  • How to Create a Physical Standby Database by Using SQL and RMAN Commands
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary