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.

Automate security audits with Lynis and Lynis Enterprise
Lynis Enterprise screenshot to help with system hardening

This blog post is part of our Linux security series to get Linux (and Unix-based) systems more secure.

Daily security checks

Want to go to the next level of security scanning and system hardening? Start with automated security scans for Linux: Lynis and Lynis Enterprise.

Automate Scanning »

Leave a Reply

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