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 13:44:53 UTC
                 RTC time: Sun 2024-04-28 13: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.

Share your love

Leave a Reply

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