Intended to help people keep daytime and evening hours straight anywhere in the world, time zones don’t really matter to a computer. It’s usually best to set your Linux time zone to match yours or the one most of your users observe. Fortunately, it’s easy to configure the time zone on Linux even after installation. Here’s how.
Why Does the Time Zone Matter in Linux?
There are a number of tasks that Linux handles according to a schedule. These can include running backups or checking for software updates. Ideally, these should run when your Linux computer isn’t being used as much, after working hours. It’s much easier to coordinate this if you set the time zone according to your own. Inevitably, you’ll need to examine log files for potential troubles. Understanding what’s happening when is a much simpler task when 5 p.m. means the same thing to you and the Linux server. Hence one more reason to make sure the time zones match.
Checking the Configured Time Zone in Linux
Linux offers a couple of ways to check the time zone. The oldest way is to check where the system’s /etc/localtime points. This is the file location set when you configure the time zone. In the early days of system administration, this was set by manually creating a symbolic link from the right time zone file to /etc/localtime. You can check this by running the command ls -l /etc/localtime from the terminal.
In this example, you can see the time zone is set to Central Standard Time, or UTC-6. The more modern method uses the timedatectl command, which is also used on today’s Linux systems to set the time zone.
Once again, we see the time zone is set for CST.
How to Change the Time Zone on Linux
We can use the same timedatectl command to change the time zone. First, though, you will need to know the correct long name of the time zone you wish to use. For several years, Linux has used long names based on the region and city to define time zones. List them by issuing the command timedatectl list-timezones from the terminal. The output will be quite lengthy, so page through it using the spacebar. After you’ve identified the correct choice, you can press q to stop the command’s list.
Let’s say we want to set the time zone according to the local time in New York City. We’ll note a listing for America/New_York, which is what we want to use. We can set it with the command sudo timedatectl set-timezone America/New_York. We then verify the change took effect using the previous empty timedatectl command.
That’s all there is to it, but what if your Linux server is older and doesn’t have timedatectl?
Using the Old Manual Symbolic Link Method to Set the Time Zone
It’s slightly more complicated to set a time zone in Linux without timedatectl, but still easy. To do this:
Using Gnome Settings to Configure the Time Zone
One last note, in case you manage your Linux computer using Gnome or some other GUI. The settings app for Gnome, KDE, and other major desktop environments will provide a way to set your Linux time zone.
Effectively Managing Your Linux Computer
Running a Linux computer properly involves a number of administrative tasks. None of them are difficult, but it can be overwhelming for a new Linux system administrator to manage. Whether it’s changing your Linux password or knowing how to search for files, we’ve got you covered. Comment Name * Email *
Δ Save my name and email and send me emails as new comments are made to this post.