How To Set Or Change Timezone On CentOS 7.
This tutorial explains how to set or change the timezone on CentOS 7.
To be able change the system’s timezone you’ll need to be logged in as root or user with sudo privileges .
Checking the Current Timezone
In CentOS and other modern Linux distros, you can use the timedatectl command to display and set the current system’s time and timezone.
The output below shows that the system’s timezone is set to UTC:
The system timezone is configured by symlinking /etc/localtime to a binary timezone identifier in the /usr/share/zoneinfo directory. So, another option to check the timezone is to show the path the symlink points to using the ls command :
Changing Timezone in CentOS
To list all available time zones, you can either list the files in the /usr/share/zoneinfo directory or use the timedatectl command.
Once you identify which time zone is accurate to your location, run the following command as sudo user:
For example, to change the system’s timezone to America/Toronto:
Run the timedatectl command to verify the changes:
Changing the Timezone by Creating a Symlink
Delete the current /etc/localtime file or symlink:
Identify the timezone you want to configure and create a symlink :
You can verify it either by listing the /etc/localtime file or issuing the date command:
In this guide, we have shown you how change your CentOS system’s timezone.