Time zones play a crucial role in ensuring that the system clock displays the correct time, particularly in a multi-user environment. Keeping the system time in sync with the right time zone helps to avoid confusion, reduce errors, and enhance the reliability of your systems.
In this article, we will cover the steps involved in configuring the time zone in CentOS Steam 9/8 and other RHEL-based systems, which is a popular Linux distribution used in enterprise environments.
Before we get started, it is important to note that you will need root access to your system to perform the steps outlined in this guide.
Step 1: View the Current Time Zone
Before making any changes to the time zone, it’s always a good idea to check the current time zone of your system. You can do this by running the following command in your terminal:
The above output showing that the current timezone is set to “Asia/Kolkata” alsoing with the current system time, date, and time zone information.
Step 2: List Available Time Zones
The CentOS Steam 9/8 and other RHEL-based system supports a large number of time zones, and you can view a list of all available time zones by running the following command:
This command will display a list of all the supported time zones, which you can use to determine the correct time zone for your system.
timedatectl list-timezones | grep "America/N"
In the above output, you will get a long list of available packages. You can also filter the output with grep command.
Step 3: Change the Time Zone
To change the time zone in RHEL/CentOS Steam 9/8, you can use the
`timedatectl set-timezone` command. For example, to change the time zone to “America/New_York”, you would run the following command:
timedatectl set-timezone America/New_York
Its always recommended to use the universal timezone (UTC) for the servers and then manager your applications accordingly. This way its easier to handle application between cross regions and timezones.
timedatectl set-timezone "UTC"
The above commands replaces the link for the /etc/localtime file and set them to requested timezone file available udner /usr/share/zoneinfo directory. Which you can also do manaully, instead of using the above commands. For example, to change timezone to the “America/New_York” time zone, you would run the following command:
ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
After running this command, the time zone change will persist across reboots.
Step 4: Verify the Change
After changing the time zone, you can verify the change by running the timedatectl command again. The output should display the updated time zone information.
You should see the updated timezone.
In conclusion, configuring the time zone in CentOS Steam 9/8 other RHEL-based systems is a straightforward process that can be performed by following these simple steps. Keeping the system time in sync with the correct time zone helps to enhance the reliability of your systems and avoid confusion.