Read in 4 minutes

last updated 

How To Set or Change Timezone on Ubuntu 18.04

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

Using the correct timezone is important for many systems related tasks and processes. For example, the cron daemon uses the system’s timezone for executing cron jobs and the timestamps in the log files are based on the same system’s timezone.

This tutorial demonstrates how to set or change the timezone on Ubuntu 18.04 and previous versions from the command line, or through the GUI. The same instructions apply for any Ubuntu-based distribution, including Kubuntu, Linux Mint and Elementary OS.

Prerequisites

You’ll need to be logged in as a user with sudo privileges in order to change the system’s timezone.

Checking the Current Timezone

In Ubuntu and most other Linux distributions, we can use the timedatectl command to display and set the current system’s time and timezone.

timedatectl

As you can see in the output below, the timezone is set to UTC:

                      Local time: Wed 2019-01-23 22:45:47 UTC
                  Universal time: Wed 2019-01-23 22:45:47 UTC
                        RTC time: Wed 2019-01-23 22:45:48
                       Time zone: Etc/UTC (UTC, +0000)
       System clock synchronized: yes
systemd-timesyncd.service active: yes
                 RTC in local TZ: no

The system timezone is configured by symlinking /etc/localtime to a binary timezone identifier in the /usr/share/zoneinfo directory. So, another option would be to show the path the symlink points to using the ls command:

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

Alternatively, you can also check the current system’s timezone by displaying the contents of the /etc/timezone file.

cat /etc/timezone
Etc/UTC

Changing the Timezone Using the timedatectl Command

Before changing the timezone, you’ll need to find out the long name for the timezone you want to use. The timezone naming convention usually uses a “Region/City” format.

To list all available time zones, you can either list the files in the /usr/share/zoneinfo directory or use the timedatectl command.

timedatectl list-timezones
...
Europe/Oslo
Europe/Paris
Europe/Podgorica
Europe/Prague
Europe/Riga
Europe/Rome
Europe/Samara
...

Once you identify which time zone is accurate to your location, run the following command as sudo user:

sudo timedatectl set-timezone your_time_zone

For example, to change the system’s timezone to Europe/Rome:

sudo timedatectl set-timezone Europe/Rome

Run the timedatectl command to verify the changes:

timedatectl
                      Local time: Thu 2019-01-24 00:27:43 CET
                  Universal time: Wed 2019-01-23 23:27:43 UTC
                        RTC time: Wed 2019-01-23 23:27:44
                       Time zone: Europe/Rome (CET, +0100)
       System clock synchronized: yes
systemd-timesyncd.service active: yes
                 RTC in local TZ: no

Changing the Timezone by Reconfiguring tzdata

If you are running an older version of Ubuntu and the timedatectl command is not present on your system you can change the timezone by reconfiguring tzdata.

  1. Identify the timezone you want to configure.
  2. Save the new timezone name to /etc/timezone file using the following tee command:

    echo "Europe/Rome" | sudo tee /etc/timezone
    Europe/Rome
  3. Run the following command to change the system’s timezone:

    sudo dpkg-reconfigure --frontend noninteractive tzdata
    Current default time zone: 'Europe/Rome'
    Local time is now:      Thu Jan 24 0048 CET 2019.
    Universal Time is now:  Wed Jan 23 2348 UTC 2019.

Changing the Timezone Using the GUI

If the command-line is not your thing, you can change the current system’s timezone through the GUI.

  1. Open the system settings window by clicking on the Settings icon as shown in the image below:

  2. In the system settings window click on the Date & Time tab, turn the Automatic Time Zone to OFF and click on the Time Zone box:

    If the Automatic Time Zone set to ON, and you have an Internet connection, the time zone should be automatically set according to your location.

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

    Once done, click on to close the window.

Conclusion

In this guide, we have shown you change your Ubuntu system’s timezone. Feel free to leave a comment if you have any questions.