This comprehensive Linux guide expects that you run the following commands as root user but if you decide to run the commands as a different user then ensure that the user has sudo access and that you precede each of the privileged commands with sudo

A time zone is nothing but a region of the globe that observes a uniform standard time for constitutional, business and cultural purposes. Using the correct timezone is important for many systems related tasks and processes. Sometimes we forgot to set timezone properly for newly installed system or sometimes we need to change timezone of systems for various testing etc. Under CentOS systems all timezone settings file are located under /usr/share/zoneinfo/ directory and /etc/localtime is the file use is used by operating system to set current timezone for system.

In this tutorial, we will show you how to change the timezone on CentOS 7 and older versions (5/6)

Set Or Change Timezone On CentOS 7

You can follow the steps given below to Set/Change timezone on CentOS 7

Checking Current Timezone

First of all, you should check your current timezone by running the following command in the terminal

[[email protected] ~]# timedatectl

      Local time: Wed 2019-07-24 22:43:42 UTC
  Universal time: Wed 2019-07-24 22:43:42 UTC
        RTC time: Wed 2019-07-24 22:43:42
       Time zone: Etc/UTC (UTC, +0000)
     NTP enabled: no
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

Displaying List Of Timezones

You can display the list of the available timezones by the following command

[[email protected] ~]# timedatectl list-timezones

Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
Africa/Bangui
Africa/Banjul
....
..
America/Dawson
America/Dawson_Creek
America/Denver
America/Detroit
America/Dominica
America/Edmonton
America/Eirunepe
America/El_Salvador
America/Fortaleza
America/Glace_Bay
....
..
Pacific/Saipan
Pacific/Tahiti
Pacific/Tarawa
Pacific/Tongatapu
Pacific/Wake
Pacific/Wallis

If you want to display the list of timezone for specific region, you can use the following command

[[email protected] ~]# timedatectl list-timezones | grep Asia

This command will display all the Asian timezones

Setting Or Changing Timezone

You can set you new timezone by using the following command

[[email protected] ~]# timedatectl set-timezone time_zone

Example:

[[email protected] ~]# timedatectl set-timezone America/Detroit

Set Or Change Timezone On CentOS 5/6

To change the timezone in CentOS 5/6 or older, you can follow the steps below

Check The Current Timezone

To check the current timezone, you can run the following command

[[email protected] ~]# date

Wed July  24 17:52:58 EST 2019

Change Timezone

Run the following commands to change your current timezone to new timezone

[[email protected] ~]# mv /etc/localtime /root/localtime.old
[[email protected] ~]# ln -s /usr/share/zoneinfo/America/Detroit /etc/localtime

Verification

Verify the new Timezone by the following command

[[email protected] ~]# date

Wed July  24 15:52:58 EST 2019