How to set or change the time zone on Ubuntu 20.04

s2 0

Using the correct time zone is essential for many system-related tasks and processes. For example, the cron daemon uses the system’s time zone to run cron jobs, and the time stamps in the log files are based on the same system time zone.

On Ubuntu, the system’s time zone is set during installation but can easily be changed at a later time.

This article describes how to set or change the time zone on Ubuntu 20.04 using the command line or GUI.

requirements

Only the root or user with sudo privileges can set or change the system’s time zone.

Check the current time zone

timedatectl is a command line utility that allows you to view and change the system time and date. It is available on all modern systemd-based Linux systems, including Ubuntu 20.04.

To print the current system’s time zone, access the timedatectl without arguments:

timedatectl

The following output shows that the system’s time zone is set to “UTC”:

               Local time: Wed 2020-05-06 19:33:20 UTC
           Universal time: Wed 2020-05-06 19:33:20 UTC
                 RTC time: Wed 2020-05-06 19:33:22    
                Time zone: UTC (UTC, +0000)           
System clock synchronized: yes                         
              NTP service: active                      
          RTC in local TZ: no   

The system time zone is configured through symlinking /etc/localtime to a binary time zone identifier in /usr/share/zoneinfo Directory.
Another option to see the current system’s time zone is to find the file that the symlink points to:

ls -l /etc/localtime
lrwxrwxrwx 1 root root 27 Dec 10 12:59 /etc/localtime -> /usr/share/zoneinfo/Etc/UTC

The system’s time zone is also included in the /etc/timezone File:

cat /etc/timezone
UTC

Change the time zone with the timedatectl command

Before changing the time zone, you need to find out the long name of the time zone you want to use. The time zones use the “Region / City” format.

To list all available time zones, you can either use the files in /usr/share/zoneinfo Directory or call the timedatectl Command with the list-timezones Opportunity:

timedatectl list-timezones
...
America/Montevideo
America/Nassau
America/New_York
America/Nipigon
America/Nome
America/Noronha
...

After determining which time zone corresponds to your location, run the following command as the sudo user:

sudo timedatectl set-timezone your_time_zone

For example, to change the system’s time zone to America/New_York:

sudo timedatectl set-timezone America/New_York

Call the timedatectl Command to check the changes:

timedatectl
               Local time: Wed 2020-05-06 15:41:42 EDT  
           Universal time: Wed 2020-05-06 19:41:42 UTC  
                 RTC time: Wed 2020-05-06 19:41:48      
                Time zone: America/New_York (EDT, -0400)
System clock synchronized: yes                         
              NTP service: active                      
          RTC in local TZ: no   

Change the time zone using the GUI

If you’re running Ubuntu Desktop, you can change the current system’s time zone through the GUI.

  1. Open the System Preferences window by clicking the Settings Icon as shown in the picture below:

  2. In the System Preferences window, click the Date & Time Tab. If the Automatic Time Zone to adjust ON and you have an Internet connection and location service turned on, the time zone should be set automatically according to your location.

  3. To select the new time zone, you can either click on the map or search for a time zone using the search bar.

    When you’re done, click × close the window.

diploma

We showed you how to change the time zone of your Ubuntu system.

Feel free to leave a comment if you have any questions.

Tags: