By default, the timezone on CentOS set at the time of installation. To change timezone in CentOS is easy and straight forward. In this guide, we will show you how to change timezone on CentOS 7.
You should logged in as a user with sudo privileges.
Get Current Timezone
You can get current timezone by simply issuing
timedatectl command. Run below command:
It will show output as below:
Local time: Thu 2019-04-25 04:20:54 UTC Universal time: Thu 2019-04-25 04:20:54 UTC RTC time: Thu 2019-04-25 04:20:54 Time zone: UTC (UTC, +0000) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: n/a
CentOS Timezone Config Files
- /usr/share/zoneinfo/ – This directory contains the files timezone name wise. For example, the file
/usr/share/zoneinfo/America/New_Yorkrepresents time zone for New York.
- /etc/localtime – This is a symlink to the file localtime located in
Change Timezone in CentOS
First, you should have long name of timezone which you want to set. You can get the list of all available timezones using below command:
It will show output like below:
Once you get timezone which you want then run the following command as sudo user.
The basic syntax is:
sudo timedatectl set-timezone new_time_zone
For example, if you want to set
America/Chicago timezone then you need to run command as :
sudo timedatectl set-timezone America/Chicago
Now you can verify timezone again using
It should show that timezone is changed to
Local time: Sat 2019-04-25 12:58:03 CDT Universal time: Sat 2019-04-25 17:58:03 UTC RTC time: Sat 2019-04-25 17:58:02 Time zone: America/Chicago (CDT, -0500) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: yes Last DST change: DST began at Sun 2019-03-10 01:59:59 CST Sun 2019-03-10 03:00:00 CDT Next DST change: DST ends (the clock jumps one hour backwards) at Sun 2019-11-03 01:59:59 CDT Sun 2019-11-03 01:00:00 CST
Change Timezone By Symlink
You can change timezone by creating a symlink also. This method is useful when your server is running older version of CentOS or not have
timedatectl command is available. We are going to change the timezone by creating symlink
/etc/localtime to the timezone in the
First, you need to delete current
/etc/localtime symlink or file by typing:
sudo rm -rf /etc/localtime
After that, add the timezone which you want to set and creating a symlink:
sudo ln -s /usr/share/zoneinfo/America/Chicago /etc/localtime
Now, if you want to verify it you can do it by listing the
/etc/localtime file or run the date command:
It will show below output:
Thu Apr 25 17:52:58 CDT 2019
Finally, you learned how to change timezone in CentOS 7. You can leave comment if you have any question.