Set or Change Timezone on CentOS 7

In this tutorial, we will learn how to set or change timezone on CentOS 7. Let’s follow these steps:

Table of Contents

  1. Prerequisites
  2. Check Current Timezone
  3. Change Timezone
  4. Change Timezone Using Symlink

Step 1 : Prerequisites

At first, we need to login to our server via SSH as root. Open your terminal and run this command:

ssh root@IPaddress -p PORT

Step 1 : Check Current Timezone

Let’s run this command to know the current system’s timezone.

timedatectl

You’ll see the output like this:

      Local time: Wed 2019-08-21 23:09:07 +06
  Universal time: Wed 2019-08-21 17:09:07 UTC
        RTC time: Wed 2019-08-21 17:09:06
       Time zone: Asia/Dhaka (+06, +0600)
     NTP enabled: n/a
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a

Step 3 : Change Timezone

The syntax of changing timezone command is:

sudo timedatectl set-timezone your_desired_time_zone

To see all available time zones, run this command:

timedatectl list-timezones

Output:

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

Select your timezone 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.


Software Engineer | Ethical Hacker & Cybersecurity...

Md Obydullah is a software engineer and full stack developer specialist at Laravel, Django, Vue.js, Node.js, Android, Linux Server, and Ethichal Hacking.