• 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. Linux OS Service ‘NetworkManager’
  2. How to Change the Default Timeout Settings for Telnet Session in CentOS/RHEL
  3. CentOS / RHEL 7 : Configuring NTP using chrony
  4. CentOS / RHEL : How to configure vsftpd to use ports other than the default ports 20 and 21
  5. How to Enable/Disable CPUs (Limiting CPU count) in CentOS / RHEL
  6. CentOS / RHEL 6,7 : How to increase system log message verbosity (rsyslogd)
  7. How to configure multicast on an IP address (interface)
  8. Linux OS Service ‘yum-updatesd’
  9. How to Configure Proxy in CentOS/RHEL/Fedora
  10. How to block non-root user from creating crontab entry in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • How to Disable IPv6 on Ubuntu 18.04 Bionic Beaver Linux
  • How to Capture More Logs in /var/log/dmesg for CentOS/RHEL
  • Unable to Start RDMA Services on CentOS/RHEL 7
  • How to rename a KVM VM with virsh
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary