For operating systems having the correct time zone is required for system tasks and processes and down to the minor parts such as logs by your applications. Having incorrect information can impact systems when setting up automatic jobs such as cron jobs that rely on the system’s timezone to execute.
For Ubuntu server users, the time zone by default is not set however, Desktop users with an active Internet connection may have this automatically set up if not, it can be set up in two different ways.
At the end of this guide, you will know how to configure Timezone on Ubuntu 20.04 LTS. The same principle will work for the newer version Ubuntu 21.04 (Hirsute Hippo).
Table of Contents
- Recommended OS: Ubuntu 20.04 – optional (Ubuntu 21.04 and Linux Mint 20)
- User account: A user account with sudo or root access.
Timezone Using Terminal
Checking the Current Timezone
First, check to see the current time zone in your Ubuntu Terminal (CTRL+ALT+T) by typing the following command:
The timezone by default is configured with a (symlink) from (/etc/localtime) to a binary timezone identifier in the (/usr/share/zoneinfo) directory which you can view the current system timezone information by finding the file where the symlink directs to by typing the following command:
ls -l /etc/localtime
Another way is to use the (cat) command to print the time from the (/etc/timezone) file by typing the command:
Changing the Timezone with (timedatectl) Command
To change the timezone settings in the Ubuntu terminal, you will first need to find the region and city format. To do this, you will use the (timedatectl) command to print this list in (Region/City) Format.
You will find a long list of region/city names, use your (up) and (down) keyboard arrow keys to navigate until you find the timezone you are after. Example below:
Once you find the correct entry, you will use (timedatectl) to set the timezone with the following command:
sudo timedatectl set-timezone your_time_zone
For our guide, we set (Australia/Queensland) using the command:
sudo timedatectl set-timezone Australia/Queensland
Next, check to see the timezone has been applied by re-entering the (timedatectl) command:
Timezone Using the GUI
Ubuntu desktop users have a secondary choice to change the timezone settings instead of using the terminal option. Using the GUI instead, this is done quicker and easier for new users to Linux and Ubuntu.
First, open the system settings, which the quickest way is by clicking in the top right-hand corner of your Ubuntu desktop screen as shown below and clicking on (settings):
Next, on the left-hand side, scroll down until you find the (Date & Time) tab and left-click on it to show the timezone settings in the right hand GUI window. By default, this should be automatically set if your operating system is connected to the Internet for desktop users.
To select the new timezone, click on the (Time Zone) on the right-hand side, currently where (AEST (Brisbane, Australia) is in our above picture. You will then see a new pop up with a map, here you use the left click of a mouse button to select your location, which will automatically change your time zone on the map.
The example below from switching to (AWST (Perth, Australia) from (AEST (Brisbane, Australia):
Once you have selected the correct timezone, click on the (X) in the top right-hand corner to apply, and that is it you have successfully changed a time zone using the GUI.
Comments and Conclusion
In the guide, you have learnt to set your timezone using the terminal and use the GUI if you have a desktop. Overall, I would suggest that novice and new users try the terminal command as it will be more entertaining to learn a new system command than using the default GUI.