Configure the time zone (TZ) on Linux systems

Linux Time Zone Configuration

Having the right time set on a Linux system is important for the synchronization of data, forensics, and troubleshooting. Having the right time zone is the next step. We will have a look on how to check and configure the time zone on Linux systems.

See current time zone

Most new Linux distributions use systemd now. By using the timedatectl command we can quickly see the existing time information, including the time zone.


See Linux time zone configuration with timedatectl

For Linux, there are typically two files related to the configuration of time zone information:

  • /etc/localtime
  • /etc/timezone

The file /etc/localtime is a binary file and is usually is a symbolic link. This file is also used by systemd. use the readlink command to see the related time zone.

readlink /etc/localtime

The output on a system in The Netherlands would be looking like this:

Time zone configuration via /etc/localtime

The /etc/timezone file is a plain text file. It usually includes the continent and place, unless a more generic setting is used like UTC.

cat /etc/timezone

Our system would show “Europe/Amsterdam”, which is the same value as the localtime file.


Time zone configuration

There are a few ways to configure the time zone on Linux distributions. Here are some of the options:

Using timedatectl (systemd)

The first option is for all Linux distributions that use systemd. There should be a timedatectl command available and allows you

timedatectl set-timezone Europe/Amsterdam

If you have multiple systems in different time zones, then UTC would be the best zone to use. This way all systems use the same information.

timedatectl set-timezone UTC

Using tzselect

Linux time zone configuration with tzselect utility

Using dpkg-reconfigure (Debian/Ubuntu)

Systems that are running Debian, Ubuntu, or similar, can use the dpkg-reconfigure tool. An interactive menu will guide you through the configuration.

dpkg-reconfigure tzdata

Time zone and scripts

The variable TZ is not exported by default on some Linux distributions. You can easily check this by using the export command.

If your Linux distribution has a /etc/profile.d directory, then most likely this is the best place to set the time zone. This way all users get the same time zone when they log in. This is only the best solution is all users on the systems are actually in the same time zone.

Configure the Linux time zone via a system-wide setting

After logging in, each user will now have this time zone as the default value. They can still override it via their local ~/.profile (home directory).


Found another way to set the configuration on your system? Let it know in the comments.

One more thing...

Keep learning

So you are interested in Linux security? Join the Linux Security Expert training program, a practical and lab-based training ground. For those who want to become (or stay) a Linux security expert.

See training package

Lynis Enterprise screenshot to help with system hardeningSecurity scanning with Lynis and Lynis Enterprise

Run automated security scans and increase your defenses. Lynis is an open source security tool to perform in-depth audits. It helps with system hardening, vulnerability discovery, and compliance.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.