How to change the time zone on Linux servers

One of the first things you should do when setting up a Linux server is double-check the time zone. While the default UTC (Coordinated Universal Time) may be fine for some systems, you might prefer to use your local time zone instead.

Checking the current time zone

We start by checking the current time zone to confirm its current state using the built-in timedatectl utility tool on Linux.

timedatectl

The output should look something like this.

               Local time: Sun 2024-04-28 11:43:58 UTC
           Universal time: Sun 2024-04-28 11:43:58 UTC
                 RTC time: Sun 2024-04-28 11:43:58
                Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

In this case, the time zone is set to UTC, which is typical for most hosts and distributions.

Changing the time zone

To check which time zones are available, run the following.

timedatectl list-timezones
...

Europe/Busingen
Europe/Chisinau
Europe/Copenhagen
Europe/Dublin
Europe/Gibraltar

...

If you wanted to set the time zone to e.g. Copenhagen, Denmark, you’d have to run the next command as either root or a sudo user.

sudo timedatectl set-timezone Europe/Copenhagen

Now, we can check again.

timedatectl
               Local time: Sun 2024-04-28 13:44:53 CEST
           Universal time: Sun 2024-04-28 11:44:53 UTC
                 RTC time: Sun 2024-04-28 11:44:53
                Time zone: Europe/Copenhagen (CEST, +0200)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

Things appear to be working as expected. You’ve now successfully changed the time zone, and this setting will persist through reboots.

Conclusion

Changing the time zone on Linux servers is a simple, yet crucial process for system-related tasks and log files to work as expected. You can learn more about timedatectl and timesyncd here.

Thank you for reading along.

2 Comments

  1. Checking the timezone is definitely one of those post-install steps I sometimes overlook until cron jobs start running at the wrong times. I usually just run timedatectl right away now to make sure it’s not stuck on the default UTC. It’s really convenient that the output also shows whether the NTP service is active so you can verify sync status at the same time.

    • I usually leave my servers on the default UTC to keep log files consistent, but timedatectl is definitely the handiest tool to quickly check if the NTP service is actually active and synced. It’s one of those minor setup details that is easy to forget until you start troubleshooting time-sensitive cron jobs.

Leave a Reply

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