[email protected]Support 24/7 · Billing 09:00 – 00:00LinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Getting startedJune 21, 2023

How To Set or Change Timezone on CentOS 7.

How To Set Or Change Timezone On CentOS 7.

This tutorial explains how to set or change the timezone on CentOS 7.

To be able change the system’s timezone you’ll need to be logged in as root or user with sudo privileges .

 

Checking the Current Timezone

In CentOS and other modern Linux distros, you can use the timedatectl command to display and set the current system’s time and timezone.

timedatectl

The output below shows that the system’s timezone is set to UTC:

 Local time: Wed 2023-06-21 05:09:09 EDT
  Universal time: Wed 2023-06-21 09:09:09 UTC
        RTC time: Wed 2023-06-21 09:09:09
       Time zone: America/New_York (EDT, -0400)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: yes
 Last DST change: DST began at
                  Sun 2023-03-12 01:59:59 EST
                  Sun 2023-03-12 03:00:00 EDT
 Next DST change: DST ends (the clock jumps one hour backwards) at
                  Sun 2023-11-05 01:59:59 EDT
                  Sun 2023-11-05 01:00:00 EST

The system timezone is configured by symlinking /etc/localtime to a binary timezone identifier in the /usr/share/zoneinfo directory. So, another option to check the timezone is to show the path the symlink points to using the ls command :

ls -l /etc/localtime
lrwxrwxrwx. 1 root root 38 Sep 25  2021 /etc/localtime -> ../usr/share/zoneinfo/America/New_York

 

Changing Timezone in CentOS

To list all available time zones, you can either list the files in the /usr/share/zoneinfo directory or use the timedatectl command.

timedatectl list-timezones
...
Europe/Athens
Europe/Belgrade
Europe/Berlin
Europe/Bratislava
Europe/Brussels
Europe/Bucharest
Europe/Budapest
Europe/Busingen
Europe/Chisinau
Europe/Copenhagen
Europe/Dublin
...

Once you identify which time zone is accurate to your location, run the following command as sudo user:

sudo timedatectl set-timezone your_time_zone

For example, to change the system’s timezone to America/Toronto:

sudo timedatectl set-timezone America/Toronto

Run the timedatectl command to verify the changes:

timedatectl
 Local time: Wed 2023-06-21 12:12:47 EEST
  Universal time: Wed 2023-06-21 09:12:47 UTC
        RTC time: Wed 2023-06-21 09:12:46
       Time zone: Europe/Bucharest (EEST, +0300)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: yes
 Last DST change: DST began at
                  Sun 2023-03-26 02:59:59 EET
                  Sun 2023-03-26 04:00:00 EEST
 Next DST change: DST ends (the clock jumps one hour backwards) at
                  Sun 2023-10-29 03:59:59 EEST
                  Sun 2023-10-29 03:00:00 EET

 

Delete the current /etc/localtime file or symlink:

sudo rm -rf /etc/localtime

Identify the timezone you want to configure and create a symlink :

sudo ln -s /usr/share/zoneinfo/America/Toronto /etc/localtime

You can verify it either by listing the /etc/localtime file or issuing the date command:

date
Wed Jun 21 12:14:47 EEST 2023

 

Conclusion

In this guide, we have shown you how change your CentOS system’s timezone.

Keep reading
Started Service enabling compressing RAM with zRam – CentOS/RHEL 7 Installation hung
February 21, 2023

Started Service enabling compressing RAM with zRam – CentOS/RHEL 7 Installation hung

Started Service enabling compressing RAM with zRam – CentOS/RHEL 7 Installation hung When installing CentOS/RHEL 7 on a hardware box with huge amount of ram installed, the installation gets hung at: [ OK ] Started Anaconda NetworkManager configuration. Starting Anaconda NetworkManager configuration…

Read article
How to add a second IP address, permanent or temporary in Linux
February 21, 2023

How to add a second IP address, permanent or temporary in Linux

How to add a second IP address, permanent or temporary in Linux Add a second temporary IP address Using ifconfig If you want to add a secondary IP address to a NIC already in use in Linux, and have that change only temporary. Enter this command: ifconfig [nic]:0 [IP-Address] netmask [mask] up An…

Read article
Using ipset to block IP addresses – firewall
February 21, 2023

Using ipset to block IP addresses – firewall

Using ipset to block IP addresses – firewall ipset is an excellent tool that can be used to efficiently block a list of IP addresses at the firewall level (it uses iptables). It really helps in easily adding IP addresses and maintaining IP address blocklists. The below guide sets up ipset to…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, cloud hosting, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Support 24/7 · Billing 09:00 – 00:00