Using the correct timezone is essential for many system-related tasks and processes. For example, the cron daemon uses the system timezone to perform cron tasks and the timestamps in the log files are based on the same system timezone.
In CentOS 8, the system time zone (time zone) is set during installation, but it can be easily changed at a later time.
This tutorial explains how to set or change the timezone in CentOS 8 systems.
You must be logged in as a user with sudo privileges to change the system time zone.
Check timezone on Ubuntu
In CentOS 8 and other modern Linux distributions, you can use the
timedatectl Display and set the current system time and time zone.
As the output below shows, the system time zone 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 receive a warning that “The system is configured to read the RTC time in the local time zone. “, Run the following command to use RTC on UTC:
System timezone is configured by communication
/etc/localtime To the binary time zone identifier in the directory
So another option to check the timezone is to check the path of the symbolic link with the ls command:
ls -l /etc/localtime
lrwxrwxrwx. 1 root root 23 Feb 21 23:30 /etc/localtime -> /usr/share/zoneinfo/UTC
Change the time zone in CentOS 8
Before changing the time zone, you must know the long name of the time zone you want to use. Typically, time zone naming conventions use the “region / city” format.
To list all available timezones, you can list files in the directory
/usr/share/zoneinfo Or use commands
... Asia/Hong_Kong Asia/Hovd Asia/Irkutsk Asia/Jakarta Asia/Jayapura Asia/Jerusalem Asia/Kabul Asia/Kamchatka Asia/Karachi Asia/Kathmandu ...
Once you have determined the exact timezone of your location, run the following command as the sudo user:
sudo timedatectl set-timezone zona_waktu_anda
For example, to change the system’s time zone to local time in Jakarta:
sudo timedatectl set-timezone Asia/Jakarta
Run the command
timedatectl To check for 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/Jakarta (WIB, +0700) System clock synchronized: yes NTP service: active RTC in local TZ: no
Change the time zone by creating a symbolic link
If you are running an older version of CentOS, the command
timedatectl Not in the system, you can change the time zone by calling
/etc/localtime To the time zone in the guide
Remove symbolic files or links from
/etc/localtime With the rm command:
sudo rm -rf /etc/localtime
Select the time zone you want to configure and symbolic linking:
sudo ln -s /usr/share/zoneinfo/Asia/Jakarta /etc/localtime
You can check this by listing the file
/etc/localtime Or use the date command:
Wed Feb 4 09:22:58 WIB 2020
In this guide, we’ve shown that you are changing your CentOS 8 timezone.