Linux Commands

How to Change the Time Zone in Linux

This tutorial explains different methods to change the timezone in Linux systems.

After reading this tutorial, you will be able to edit your Linux timezone using different techniques. This content is optimized for all level Linux users, you only need privileged execution permissions.

Below, you will find instructions to edit your timezone by using the timedatectl clock controller from the desktop environment and by replacing a soft link.

All steps shown in this article include screenshots, making it easy for every user to follow them.

How to change the Linux system timezone using the timedatectl command

This section explains how to change the timezone in Linux using the timedatectl command. timedatectl command is used to check and control the system clock, date, timezone and its settings, as well as enabling or disabling time synchronization services.

To check our current timezone, we can execute the timedatectl command without additional options, as shown in the screenshot below.

1
timedatectl

As you can see, my current timezone is America/Argentina/Buenos_Aires.

Alternatively, you can check your current timezone by running the command followed by the show option as shown below.

1
timedatectl show

As shown above, running timedatectl without arguments returns a more comprehensive output, but either ways are valid to get your current timezone.

To list available timezones and to change it in your Linux system, run timedatectl followed by the list-timezones option as shown in the following figure.

Press the down arrow key to continue listing available timezones.

1
timedatectl list-timezones

For this example, I will change my time zone to Africa/Cairo. Just copy the timezone exactly as listed and run the command below. Africa/Cairo must be replaced with your country.

1
sudo timedatectl set-timezone Africa/Cairo

Then you can check if settings were properly changed by running timedatectl again.

1
timedatectl

As you can see, the timezone was properly edited.

Change your timezone in Linux from the graphical environment

This section shows how to change the timezone from the desktop environment.

Note: Depending on your X Window manager, the steps may be different. Keep in mind that you need to find the System administration panel and select Time and Date settings.

In most X Window managers, press System, in the dropdown menu press Administration and then press Time and Date.

You need privileges to change your zonetime, press the Unlock button as shown below.

Type your password and press the Authenticate button.

Press the Time zone dropdown menu as shown below.

Now press the Selection dropdown menu.

Choose the new time zone.

Press the Close button to apply changes.

As you can see, the time zone was properly edited. In the graphical environment, probably you will need to logout and login back.

Keep reading below for a third way to edit your timezone.

Changing your timezone in Linux by implementing a soft link

Contrary to hard links, soft links or symbolic links are not copies of the original file but a path to a specific file. Therefore, if the original file is removed, the soft or symbolic link will point out to no file becoming an orphaned link. This means, if you delete or move the original file, the soft link will lose access to the information. While with the hard link, the information remains despite the source file removal because it is a file clone.

In the instructions below, we will replace the current soft link for a new one pointing out to the proper timezone.

Available timezones are stored in the /usr/share/zoneinfo directory. To see available timezones, use the ls command as shown below.

1
ls /usr/share/zoneinfo

Within the /etc/sha/zoneinfo file you will see subdirectories and files. In my case, my country is inside two other subdirectories (America and Argentina). Before proceeding, I would check for available countries in the America subdirectory by using the ls command again (you can also use the TAB key to autocomplete names).

1
ls /usr/share/zoneinfo/America/

Finally, let’s check options within the Argentina subdirectory. I will find a file (No directory) pointing to my city or state.

The entire path to this file, including the file name is the path we will use for the soft link. In this case my path is /usr/share/zoneinfo/America/Argentina/Buenos_Aires.

1
ls /usr/share/zoneinfo/America/Argentina/

Before creating the symbolic link, backup the current one by running the following command:

1
sudo mv /etc/localtime /etc/localtime.bak

To add the new soft link run the command below, replacing my path with yours.

1
sudo ln -s /usr/share/zoneinfo/America/Argentina/Buenos_Aires /etc/localtime

As you can see, the timezone was successfully edited.

Conclusion:

By following the instructions described above in this article, any user can edit the timezone and clock. It is important to clarify the first method, first. Second methods are the most correct, but as you can see, all of them are functional. Linux flexibility allows users to achieve the same tasks through different techniques in contrast to other systems like Windows. There are additional tools you can download to edit timezone settings, but this tutorial only covered native methods.

About the author

David Adams

David Adams is a System Admin and writer that is focused on open source technologies, security software, and computer systems.