Using the correct time zone is essential for many system-related tasks and processes. For example, the cron daemon uses the system timezone to execute cron jobs and timestamps in the log file are based on the same system timezone.
On the Rocky Linux 8.4 and CentOS 8 operating system, the system timezone is set during installation, but can be easily changed at a later time.
This tutorial explains how to set or change the time zone on Rocky Linux 8.4 and CentOS 8 systems.
You must be logged in as a user with sudo privileges to change the system timezone.
Check Timezone in Ubuntu
On Rocky Linux 8 and other modern Linux distros, you can use the command
timedatectlto display and set the current system time and timezone.
As the output below shows, the system timezone is set to UTC:
Local time: Sat 2020-03-21 21:30:22 UTC Universal time: Sat 2020-03-21 21:30:22 UTC RTC time: Sat 2020-03-21 21:30:22 Time zone: UTC (UTC, +0000) System clock synchronized: yes NTP service: active RTC in local TZ: no
If you get a warning that says, ” The system is configured to read the RTC time in the local time zone .”, Run the following command to use the RTC in UTC:
The system time zone is configured by connecting
/etc/localtimeto the binary timezone identifier in the directory
So, another option to check the timezone is to check the path symlink by using the ls command :
ls -l /etc/localtime
lrwxrwxrwx. 1 root root 23 Feb 21 23:30 /etc/localtime -> /usr/share/zoneinfo/UTC
Changing Time Zone on Rocky Linux 8.4 and CentOS 8
Before changing the time zone, you must find out the long name for the time zone you want to use. Time zone naming conventions usually use the “Region/City” format.
To list all available time zones, you can list files in the directory
/usr/share/zoneinfoor use commands
... Asia/Hong_Kong Asia/Hovd Asia/Irkutsk Asia/Jakarta Asia/Jayapura Asia/Jerusalem Asia/Kabul Asia/Kamchatka Asia/Karachi Asia/Kathmandu Asia/Kolkata ...
Once you’ve identified which timezone is accurate for your location, run the following command as the sudo user:
sudo timedatectl set-timezone your_timezone
For example, to change the system timezone to Kolkata local time:
sudo timedatectl set-timezone Asia/Kolkata
timedatectlto verify changes:
Local time: Sat 2020-04-21 07:43:39 WIB Universal time: Sat 2020-04-21 00:43:39 UTC RTC time: Sat 2020-04-21 00:43:40 Time zone: Asia/Kolkata (WIB, +0700) System clock synchronized: yes NTP service: active RTC in local TZ: no
Changing the Time Zone by Creating a Symlink
If you are running an version of Rocky Linux or CentOS older , and command
timedatectlis not in the system, you can change the time zone by connecting
/etc/localtimeto the timezone in the directory
Delete the file or symlink from
/etc/localtimewith the command rm :
sudo rm -rf /etc/localtime
Identify the timezone you want to configure and create a symlink:
sudo ln -s /usr/share/zoneinfo/Asia/Jakarta /etc/localtime
You can verify it by listing the file
/etc/localtimeor use the date command :
Wed Feb 4 09:22:58 WIB 2020
In this guide, we have shown you changing the timezone of your Rocky Linux 8.4 and CentOS 8 system.