How to Set or Change Time zone in Ubuntu

It is important to use the correct time zone in Linux systems, since many applications and processes use it as a reference. In most cases, the system time zone is set during installation but it can be changed later on also. In this article, we will look at how to set or change Time Zone in Ubuntu.


How to Set or Change Time zone in Ubuntu

Here are the steps to set or change time zone in Ubuntu. We will use timedatectl tool to change system time zone.


Check Current Time Zone

First, we will check our current time zone by simply entering timedatectl command without any options.

$ timedatectl

You will see the following output.

                      Local time: Tue 2019-12-03 16:30:44 UTC
                  Universal time: Tue 2019-12-03 16:30:44 UTC
                        RTC time: Tue 2019-12-03 16:30:44
                       Time zone: Etc/UTC (UTC, +0000)
       System clock synchronized: no
systemd-timesyncd.service active: yes
                 RTC in local TZ: no

In most Linux systems, the default time zone is set to UTC, as you can see above.

Also read : How to Implement SSL/TLS in Apache Tomcat



Change Time Zone

Before we set or change time zone in Linux, we need to know the name of our time zone that we need to use. For this purpose, we will list the available time zones using the following command.

$ timedatectl list-timezones

You will see the following output.

...
America/Montserrat 
America/Nassau 
America/New_York
...

Once you have found out the name of your time zone, you can set or change it with the following command.

$ sudo timedatectl set-timezone <time_zone_name>

For example, if you want to set time zone to New York, here is the command for it.

$ sudo timedatectl set-timezone America/New_York

Once again, let us check the current time zone to ensure that the changes have been applied correctly.

$ timedatectl
                      Local time: Tue 2019-12-03 13:55:09 EST
                  Universal time: Tue 2019-12-03 18:55:09 UTC
                        RTC time: Tue 2019-12-03 18:02:16
                       Time zone: America/New_York (EST, -0500)
       System clock synchronized: no
systemd-timesyncd.service active: yes
                 RTC in local TZ: no

As you can see above, the system time zone has been updated to New York’s time zone.

That’s it. It is very easy to change system time zone in Linux using timedatectl command.

Also read : How to Extract data from JSON file in Python


Set time zone on Old Linux versions

If you are running an old Linux version, timedatectl may not be available on it. In such cases, you can simply symlink /etc/localtime to the time zone of your choice in /usr/share/localtime

Here is an example to create a symlink to New York time zone.

$ sudo ln -s /usr/share/zoneinfo/America/New_York /etc/localtime

Once you have set the time zone, you can verify it with date command.

$ date

Also read : How to Install Laravel with NGINX