By default, the timezone on CentOS set at the time of installation. CentOS and RedHat still use symbolically linked files to set the system's timezone. Basically, the timedatectl command is a relatively new addition to Systemd distributions, and provides a much simpler interface for viewing and adjusting a server's date and time.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related Linux queries.
In this context, we shall look into how to change timezone on CentOS 7.
Before proceeding with this procedure, ensure that you are using a user with sudo privileges.
You can get current timezone by simply issuing timedatectl command. Run below command:
$ timedatectlIt 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/aCentOS Timezone Config Files
How to 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:
$ timedatectl list-timezonesIt will show output like below:
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
Africa/Bangui
...
...
America/Caracas
America/Cayenne
America/Cayman
America/Chicago
America/Chihuahua
America/Costa_Rica
...
...
Pacific/Saipan
Pacific/Tahiti
Pacific/Tarawa
Pacific/Tongatapu
Pacific/Wake
Pacific/Wallis
UTCOnce you get timezone which you want then run the following command as sudo user.
The basic syntax is:
$ sudo timedatectl set-timezone new_time_zoneFor example, if you want to set America/Chicago timezone then you need to run command as :
$ sudo timedatectl set-timezone America/ChicagoNow you can verify timezone again using timedatectl command:
$ timedatectlIt should show that timezone is changed to America/Chicago.
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 CSTHow to 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 /usr/share/zoneinfo directory.
First, you need to delete current /etc/localtime symlink or file by typing:
$ sudo rm -rf /etc/localtimeAfter that, add the timezone which you want to set and creating a symlink:
$ sudo ln -s /usr/share/zoneinfo/America/Chicago /etc/localtimeNow, if you want to verify it you can do it by listing the /etc/localtime file or run the date command:
$ dateIt will show below output:
Output
Thu Apr 25 17:52:58 CDT 2019This article covers how to change timezone in CentOS 7. A time zone is basically a region of the globe that observes a uniform standard time for constitutional, business and cultural purposes.
To get detailed information your CentOS server's date, time, and timezone you use the timedatectl command:
$ timedatectlTo Delete the current /etc/localtime file or symlink:
$ sudo rm -rf /etc/localtime