Ubuntu

How to change the time zone on Ubuntu 20.04

Having the right time zone on your system is very important as it do a lot more than merely displaying the time. If the time zone is not set correctly, it can have an impact on server logs, reporting, email, and file timestamps. Not only this, the wrong time zone can also make the reminders and the cron jobs to run at different than expected time. Therefore, after installing the OS, it’s a very essential step to set a right time zone on your system. You can let your system to automatically choose the time zone by syncing with the internet servers. To manually change the time zone on your system, you can use either the GUI or command-line.

This article will explain to you how to manually change the time zone on your Ubuntu system via both GUI and the command line. You can use either of these ways based on your preferences to change the time zone.

Note that, we have run the commands and procedure mentioned in this article on a Ubuntu 20.04 system.

View current time zone Via GUI

In order to view the current time zone information via GUI, follow the steps below:

Hit the super key on your keyboard and type date and time. When the result appears as follows, click on the Date & Time in front of the Settings utility.

Now the Settings utility will open in Date and Time view, where you can see your system’s current time zone.

View current time zone Via Command line

Open the command-line Terminal in your Ubuntu OS either through the right-click menu or through the Ctrl+Alt+T keyboard shortcut.

Then in the Terminal, execute the following command in order to view the current time zone information:

$timedatectl

In the output, you will see the current time zone as well as other details about your system.

You can also find the current time zone of your system by viewing the /etc/localtime file. To do so, use the ls command as follows:

$ ls –l /etc/localtime

Change time zone Via GUI

In order to change the time zone of your system via GUI, open the Settings utility in Date & Time view as follows.

Now turn the toggle switch Automatic Time Zone to slide it to off position, if it is turned on. Then click the Time Zone option in order to change the time zone of your system.

In the following map, search for the time zone manually by typing the relevant keyword in the search bar. You can also use your mouse cursor on the map to locate your time zone.

After selecting the time zone, close the window. Now the new time zone will be set on your system.

Change time zone Via Command line

To list the time zones related to a specific region, use the following syntax:

$ timedatectl list-timezones | grep -i [zone]

For instance, to list all the time zones specific to Asia region, the command would be:

$ timedatectl list-timezones | grep -i asia

To change the time zone of your system via command line, follow the below simple procedure:

Here, we will change our system’s time zone to Pakistan/Karachi. To do so, you will need to first remove the link to the localtime file using the following command in Terminal:

$ sudo unlink /etc/localtime

Now, you can set a new timezone for our system. For that, use the following syntax in Terminal:

$ sudo ln -s /usr/share/zoneinfo/[TimeZone] /etc/localtime

In our case, the command would be:

$ sudo ln -s /usr/share/zoneinfo/Europe/Istanbul /etc/localtime

Now the new time zone of your system will be changed. To verify the new time zone, execute the following command:

$ timedatectl

That’s all there is to it! In this article, you have learned how to view and to change the time zone on the Ubuntu 20.04 system via GUI and the command line. I hope this will be helpful if you ever have to configure correct time zone on your Ubuntu system.

About the author

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.