How To Set Or Change The Time Zone In Linux
This tutorial covers the steps necessary to set or change the time zone in Linux.
A time zone is a geographic region that has the same standard time. Typically the time zone is set during the installation of the operational system, but it can be easily changed at a later time.
Checking the Current Time Zone
timedatectl is a command-line utility that allows you to view and change the system’s time and date. It is available on all modern systemd-based Linux systems.
To view the current time zone, invoke the timedatectl command without any options or arguments:
The output above shows that the system’s time zone is set to UTC.
The system time zone is configured by symlinking the /etc/localtime file to a binary time zone’s identifier in the /usr/share/zoneinfo directory.
Another way to check the time zone is to view the path the symlink points to using the ls command:
Changing the Time Zone in Linux
Before changing the time zone, you’ll need to find out the long name of the time zone you want to use. The time zone naming convention usually uses a “Region/City” format.
To view all available time zones, use the timedatectl command or list the files in the /usr/share/zoneinfo directory:
Once you identify which time zone is accurate to your location, run the following command as root or sudo user:
For example, to change the system’s timezone to Europe/Bucharest you would type:
To verify the change, invoke the timedatectl command again:
Mission accomplished! You’ve successfully changed your system’s time zone.
Changing the Time Zone by Creating a Symlink
If you are running an older Linux distribution and the timedatectl utility is not present on your system, you can change the timezone by symlinking /etc/localtime to the time zone in the /usr/share/zoneinfo directory.
Remove the current symlink or file:
Identify the timezone you want to configure and create a symlink :
Verify it either by listing the /etc/localtime file or invoking the date command:
The output includes the time zone, in this example that is “EST”.
To change the time zone in Linux systems use the sudo timedatectl set-timezone command followed by the long name of the time zone you want to set.