Best 3 Steps To Update Timezone DB in Linux (tz or zoneinfo)

In this tutorial, we want to teach you to Update Timezone DB in Linux (Zoneinfo). The Time Zone Database is often called tz or zoneinfo. Sometimes database of the timezone in Linux is wrong or after any changes in the timezone, you must manually update the timezone DB, or update the tzdata.

You can update zoneinfo files with your Linux package manager. To do this, you can install and update the tzdata package on your Linux server and fix up the zoneinfo files.

Steps To Update Timezone DB in Linux

To Update Timezone DB in Linux, you must have access to your server as a root or non-root user with sudo privileges. You can visit the Orcacore website and check for the Linux initial setup guides. In this guide, you will learn to:

  • Install the tzdata package on Rhel-based and Debian-based distros
  • Update tzdata package
  • Update zoneinfo files manually

Step 1 – Install and Update tzdata on Centos / AlmaLinux / RHEL

At this point, you can use YUM and DNF which are the default package manager in the RHEL-based distro to install the tzdata package. First, run the system update on Linux:

# sudo yum update #centos7,RHEL7
# sudo dnf update #centos 8, AlmaLinux 8,9, RHEL 8,9

Then, use the command below to install the tzdata package in order to Update Timezone DB in Linux:

# sudo yum install tzdata #centos7,RHEL7
# sudo dnf install tzdata #centos 8, AlmaLinux 8,9, RHEL 8,9

If the tzdata packages are available on your Linux system, you must update the tzdata on your Linux server:

# sudo yum update tzdata #centos7,RHEL7
# sudo dnf update tzdata #centos 8, AlmaLinux 8,9, RHEL 8,9

Step 2 – Install and Update tzdata on Ubuntu / Debian

If you are using Debian-based distros, you can use the apt package manager to install and update tzdata on your server.

First, run the system update on Debian or Ubuntu Linux:

sudo apt update

Then, use the command below to install the tzdata package:

sudo apt install tzdata

If the tzdata packages are available on your Linux system, you must update the tzdata on your Linux server to Update Timezone DB in Linux:

sudo apt update tzdata

Note: If you were unable to install or update the tzdata package, were unable to find a tzdata package, or don’t have a functional package manager, you can still update your zoneinfo files manually. Proceed to the next step to do it.

Step 3 – Update zoneinfo Files Manually in Linux

At this point, you must visit the Time Zone Database page and get the latest package of tzdata by using the following wget command:

sudo wget https://data.iana.org/time-zones/releases/tzdata2023c.tar.gz

Then, extract your downloaded file with the command below:

sudo tar -xvzf tzdata2023c.tar.gz

The zic command is a Linux program that reads the text containing the time zone from a file and creates the correct time conversion based on the specified command and timezone.

You now need to compile a file based on your timezone. For instance, if your timezone is EDT, your file is named North America. So, to compile it, append its name to zic, as shown in the following command:

sudo zic -d zoneinfo northamerica

Then, switch to your zoneinfo directory:

cd zoneinfo

Next, copy the file into the path with your time zone. To do this, run the command below:

sudo cp -r * /usr/share/zoneinfo/

Now you can test that the proper dates and times are found in your zoneinfo files on your Linux server. For example:

zdump -v America/Chicago | grep 2009
test dates and times in your zoneinfo files on your Linux

This will find zoneinfo files for the 2009 DST changes.

Then, Simply run date from the command line and verify that the correct date and time are reported. 

Conclusion

At this point, you have learned to Update Timezone DB in Linux. You can install or update tzdata or manually update zoneinfo files on your Linux distros.

Hope you enjoy it. You may be interested in these articles:

Fix PuTTY Server Refused Our Key Error

Create Tar.Gz File in Linux

Clear DNS Cache in Linux

Share your love

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!