How to change the system time zone from command line in Red Hat Enterprise Linux 6 and earlier
Environment
- Red Hat Enterprise Linux 3
- Red Hat Enterprise Linux 4
- Red Hat Enterprise Linux 5
- Red Hat Enterprise Linux 6
Issue
- How can the system timezone be changed from the command line without using
system-config-date(orredhat-config-datein RHEL3)?
Resolution
Note: On RHEL 7, there is a different procedure to change time zone from command line.
-
Find the desired time zone file in the
/usr/share/zoneinfo/directory, for example: "America/New_York", be sure the file /etc/localtime is not a symbolic link or the change will not work:# file /etc/localtime /etc/localtime: symbolic link to `/usr/share/zoneinfo/US/Mountain' # unlink /etc/localtime -
Edit
/etc/sysconfig/clockand change theZONE=declaration in to ensure the time zone is read properly by thetzdata-updatecommand each time the tzdata package gets updated (or whensystem-config-dateis run), e.g.:ZONE="America/New_York" -
And finally, run
tzdata-updatewhich will reconfigure your system time zone, write the new/etc/localtimeand notify the operating system that there was a time zone change. There's no need to reboot.# tzdata-update -
Run the
datecommand to ensure it reports the expected time and date.
Notes on UTC
-
It is generally advisable to configure the system clock to use UTC, which results in the BIOS storing the time in UTC (Content from en.wikipedia.org is not included.Coordinated Universal Time) instead of local time.
- This is especially recommended if a system is configured with a time zone that observes Content from en.wikipedia.org is not included.daylight saving time or if the system's users will connect remotely from other time zones.
- This is not recommended if the system is configured to dual-boot with Microsoft Windows.
-
To enable UTC in RHEL 6, ensure the third line of
/etc/adjtimereads as follows:UTC- See
man hwclockunder the Adjust Function header for details on the/etc/adjtimefile.
- See
-
To enable UTC in earlier versions of RHEL, ensure
/etc/sysconfig/clockcontains a line like the following:UTC=true- See
/usr/share/doc/initscripts*/sysconfig.txtfor details on the/etc/sysconfig/clockfile.
- See
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.