How To Change Time Zone in CentOS 8 / RHEL 8

ADVERTISEMENT

Change Time Zone in CentOS 8
Change Time Zone in CentOS 8

The time zone is often set during the installation of an operating system. There are some possibilities you might have chosen the wrong time zone or you want to change the time zone post the installation of an operating system.

In either case, this post will help you to change the time zone in CentOS 8 / RHEL 8.

Change Time zone in CentOS 8 / RHEL 8

We can change the time zone in two ways,

1. Using timedatectl command

2. Using /etc/localtime file

Let us get straight into the topic.

1. Using timedatectl command

The timedatectl command makes it easier for us to change the time zone in CentOS 8 / RHEL 8.

Now, first, let’s check the date with the date command.

date

Output:

Mon Dec 2 21:53:05 EST 2019

You can see that my system has been configured with Eastern Standard Time (EST).

Use the following command to list all time zones.

timedatectl list-timezones

Output:

Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
Africa/Bangui
. . .
. . . Pacific/Saipan
Pacific/Tahiti
Pacific/Tarawa
Pacific/Tongatapu
Pacific/Wake
Pacific/Wallis
UTC

You can filter the output based on the city name. Chicago falls under Central Standard Time (CST).

timedatectl list-timezones | grep -i chicago

Output:

America/Chicago

Now, I will set the system time zone as Central Standard Time (CST) by using America/Chicago.

ADVERTISEMENT

timedatectl set-timezone America/Chicago

Verify the new time zone using the date command.

date

Output:

Mon Dec 2 21:00:37 CST 2019

2. Using /etc/localtime file

In this method, we will set the system time zone from EST to CST. Check the current time zone using the date command.

date

Output:

Mon Dec 2 22:01:43 EST 2019

You can see that my system has been configured with Eastern Standard Time (EST).

In this method, we will use /etc/localtime file to set the time zone for the system. The /etc/localtime file is a link to the original time zone file found under the/usr/share/zoneinfo directory.

ls -al /etc/localtime

Output:

lrwxrwxrwx. 1 root root 36 Dec 2 22:01 /etc/localtime -> /usr/share/zoneinfo/America/New_York

The /usr/share/zoneinfo/ directory contains all the time zones. Beneath that you can find directories specific to country or zone. For example, the /usr/share/zoneinfo/America/ directory contains American time zones.

ls /usr/share/zoneinfo/America/

Output:

Adak Campo_Grande Eirunepe Iqaluit Merida Porto_Acre St_Johns
Anchorage Cancun El_Salvador Jamaica Metlakatla Port_of_Spain St_Kitts
Anguilla Caracas Ensenada Jujuy Mexico_City Porto_Velho St_Lucia
Antigua Catamarca Fortaleza Juneau Miquelon Puerto_Rico St_Thomas
Araguaina Cayenne Fort_Nelson Kentucky Moncton Punta_Arenas St_Vincent
Argentina Cayman Fort_Wayne Knox_IN Monterrey Rainy_River Swift_Current
Aruba Chicago Glace_Bay Kralendijk Montevideo Rankin_Inlet Tegucigalpa
Asuncion Chihuahua Godthab La_Paz Montreal Recife Thule
Atikokan Coral_Harbour Goose_Bay Lima Montserrat Regina Thunder_Bay
Atka Cordoba Grand_Turk Los_Angeles Nassau Resolute Tijuana
Bahia Costa_Rica Grenada Louisville New_York Rio_Branco Toronto
Bahia_Banderas Creston Guadeloupe Lower_Princes Nipigon Rosario Tortola
Barbados Cuiaba Guatemala Maceio Nome Santa_Isabel Vancouver
Belem Curacao Guayaquil Managua Noronha Santarem Virgin
Belize Danmarkshavn Guyana Manaus North_Dakota Santiago Whitehorse
Blanc-Sablon Dawson Halifax Marigot Ojinaga Santo_Domingo Winnipeg
Boa_Vista Dawson_Creek Havana Martinique Panama Sao_Paulo Yakutat
Bogota Denver Hermosillo Matamoros Pangnirtung Scoresbysund Yellowknife
Boise Detroit Indiana Mazatlan Paramaribo Shiprock
Buenos_Aires Dominica Indianapolis Mendoza Phoenix Sitka
Cambridge_Bay Edmonton Inuvik Menominee Port-au-Prince St_Barthelemy

Now, create a link with the desired time zone. In my case, for Central Standard Time (CST) timezone.

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

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

Here, you can link either the City or Zone with /etc/localtime. Chicago falls under Central Standard Time (CST).

Verify the time zone using the date command.

date

Output:

Mon Dec 2 21:04:07 CST 2019

Conclusion

That’s All. I hope this post helped you to change time zone in CentOS 8 / RHEL 8. Please share your thoughts in the comments section.