How to Change Timezone on RHEL / CentOS 7 and 8

How to Change Timezone on RHEL / CentOS 7 and 8

How to Change Timezone on RHEL / CentOS 7 and 8

In this article, I’m going to share how to change the timezone on RHEL / CentOS 7 & 8.

Table of Contents

  1. Check Current Timezone
  2. Available Timezones
  3. Change Timezone
  4. Change Timezone Using Symlink

Check Current Timezone

Using these commands we can see the current date & time:

1. Using date command:

Tue Jan 28 16:09:48 +06 2020

2. Using ls -l /etc/localtime command:

lrwxrwxrwx 1 root root 32 Jan 27 15:44 /etc/localtime -> ../usr/share/zoneinfo/Asia/Dhaka

3. Using timedatectl command:

               Local time: Tue 2020-01-28 16:21:31 +06
           Universal time: Tue 2020-01-28 10:21:31 UTC
                 RTC time: Tue 2020-01-28 10:21:31
                Time zone: Asia/Dhaka (+06, +0600)
System clock synchronized: no
              NTP service: n/a
          RTC in local TZ: no

Available Timezones

To see available time zones, we need to run a command like:

# all timezones
timedatectl list-timezones
# timezones of Asia
timedatectl list-timezones | grep Asia

You’ll see the output like:

......
Asia/Dhaka
Asia/Dili
Asia/Dubai
Asia/Dushanbe
Asia/Famagusta
Asia/Gaza
......

Change Timezone

The syntax of changing timezone command is:

sudo timedatectl set-timezone your_timezone

Select your time zone from the list. To set Asia/Dhaka, run this command:

sudo timedatectl set-timezone Asia/Dhaka

Step 4 : Change Timezone Using Symlink

If your server doesn’t work timedatectl command, then follow this method. We need to delete localtime first:

sudo rm -rf /etc/localtime

Then set the timezone like this:

sudo ln -s /usr/share/zoneinfo/Asia/Dhaka /etc/localtime

Now check the timezone.

The article is over. Thanks for reading. ?

StarCode Kh

Website that learns and reads, PHP, Framework Laravel, How to and download Admin template sample source code free.

Post a Comment

Previous Post Next Post
close