How To Set or Change Timezone on Ubuntu 18.04
4 min read
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 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.
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.
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
Changing the Timezone Using the
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
... 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
sudo timedatectl set-timezone Europe/Rome
timedatectl command to verify the changes:
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
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
Identify the timezone you want to configure.
Save the new timezone name to
/etc/timezonefile using the following tee command:
echo "Europe/Rome" | sudo tee /etc/timezone
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 00:40:48 CET 2019. Universal Time is now: Wed Jan 23 23:40:48 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.
Open the system settings window by clicking on the
Settingsicon, as shown in the image below:
In the system settings window click on the
Date & Timetab, turn the
Automatic Time Zoneto
OFFand click on the
Automatic Time Zoneset to
ONand you have an Internet connection, the time zone should be automatically set according to your location.
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.
In this guide, we have shown you change your Ubuntu system's timezone. Feel free to leave a comment if you have any questions.