6 C
Texas

How To Change Time Zone in CentOS 8 / RHEL 8

Time zone can be set while Installing your system but many times you choose the default time zone or the wrong one. In this guide, you will learn that how you can change the time zone after the Installation of your Operating System. Follow the steps to easily change your time zone on CentOS 8 / RHEL 8

Changing Time Zone in CentOS 8 / RHEL 8

There are two methods that can be used to change the time zone in your CentOS 8 system.

  • By using Timedatectl Command
  • By using /etc/localtime file

We will look over both methods to change time zone on our CentOS system.

Using timedatectl command

Check the current time zone by typing date in your Terminal

- Advertisement -
[sabi@localhost ~]$ date
Mon Dec 23 05:40:27 EST 2019

First, list the available time zone by typing the below command in your terminal.

timedatectl list-timezones

Output will list all available Time zones like

Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
Africa/Blantyre
Africa/Brazzaville
Africa/Bujumbura
Africa/Cairo
Africa/Casablanca
Africa/Ceuta
Africa/Conakry
Africa/Dakar
Africa/Dar_es_Salaam
Africa/Djibouti
Africa/Douala
Africa/El_Aaiun
Africa/Freetown
Africa/Gaborone
Africa/Harare
Africa/Johannesburg
Africa/Juba
Africa/Kampala
Africa/Khartoum
Africa/Kigali
Africa/Kinshasa
Africa/Lagos
Africa/Libreville
Africa/Lome
Africa/Luanda
Africa/Lubumbashi
Africa/Lusaka
Africa/Malabo

Now, choose the desire one which you want to set up on your CentOS system. You can also filter the time zone for your cities by running

timedatectl list-timezones | grep -i chicago

Output:

Africa/Accra

In my case I’m setting to Africa/Accra.

timedatectl set-timezone Africa/Accra

You can verify the time zone by running

date

Output:

[sabi@localhost ~]$ date
Mon Dec 23 10:46:27 GMT 2019

Using /etc/localtime file

We can also set the time zone by the local time file. We’ll change the time zone from GMT to EST. Use the date command to see the current time zone.

date

Output:

 [sabi@localhost ~]$ date
Mon Dec 23 10:46:27 GMT 2019

here you can see that my system is Configured with Greenwich Mean Time (GMT)

Now, use ls command to list the all time zones in /usr/share/zoneinfo/. You can also navigate to the country specific directory like /usr/share/zoneinfo/Africa directory would contain the Africa Time Zone.

[sabi@localhost ~]$ ls /usr/share/zoneinfo/Africa
Abidjan Bissau Dar_es_Salaam Kampala Lusaka Niamey
Accra Blantyre Djibouti Khartoum Malabo Nouakchott
Addis_Ababa Brazzaville Douala Kigali Maputo Ouagadougou
Algiers Bujumbura El_Aaiun Kinshasa Maseru Porto-Novo
Asmara Cairo Freetown Lagos Mbabane Sao_Tome
Asmera Casablanca Gaborone Libreville Mogadishu Timbuktu
Bamako Ceuta Harare Lome Monrovia Tripoli
Bangui Conakry Johannesburg Luanda Nairobi Tunis
Banjul Dakar Juba Lubumbashi Ndjamena Windhoek

Create a link with the time zone you want to use. I’m using for CST ( Central Standard Time)

ln -sf /usr/share/zoneinfo/US/Eastern /etc/localtime

OR

ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime

After setting up, verify the changes

date

Output:

[sabi@localhost ~]$ date
 Mon Dec 23 10:46:27 CST 2019

So in this way, you can change time zone in CentOS 8 / RHEL 8.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article