×


Change Timezone on Ubuntu 18.04 - Step by Step Process ?

Timezone is set at the time of installation of Ubuntu OS and you also can change it later. It's very important aspect to set up a proper timezone for applications which are based on cron jobs and the timestamps.

Modern operating systems detect and synchronize time using NIST (National Institute of Standards and Technology) time servers. NIST operates an atomic clock that neither gains nor loses a second in 300 million years.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related Ubuntu queries.

In this context, we shall look into different methods to change timezone on Ubuntu 18.04 system.


How to Get Current Timezone ?

Before proceeding with this configuration procedure, ensure that you are using a user account with sudo privileges.

Basically, timedatectl command is same for all Linux distributions and used to get and set system's timezone easily. Execute the below command to get current timezone:

$ timedatectl

It will display output as below:

                  Local time: Tue 2021-04-30 11:57:15 IST
                  Universal time: Tue 2021-04-30 06:27:15 UTC
                        RTC time: Tue 2021-04-30 06:27:15
                       Time zone: Asia/Kolkata (IST, +0530)
       System clock synchronized: yes
systemd-timesyncd.service active: yes
                 RTC in local TZ: no


Timezone Config Files on Ubuntu

  • /usr/share/zoneinfo/ – Timezone name wise files are stored in this directory. For example, the file /usr/share/zoneinfo/America/New_York represents time zone for New York.
  • /etc/localtime – This is a symlink to the file localtime located in /usr/share/zoneinfo/ directory.


How to Change Timezone in Ubuntu ?

To begin, you should know long name for timezone which you want to set. To get the list of all available timezones run below command:

$ timedatectl list-timezones

It will show output like below:

Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
Africa/Bangui
...
...
America/Caracas
America/Cayenne
America/Cayman
America/Chicago
America/Chihuahua
America/Costa_Rica
...
...
Pacific/Saipan
Pacific/Tahiti
Pacific/Tarawa
Pacific/Tongatapu
Pacific/Wake
Pacific/Wallis
UTC

Take long name of timezone which you want to set and run the following command as with sudo user.

The basic syntax for command is:

$ sudo timedatectl set-timezone NEW_TIME_ZONE

For example, if your required timezone is America/New_York then you can set it by running command as below :

$ sudo timedatectl set-timezone America/New_York

Now verify timezone again using timedatectlcommand:

$ timedatectl

It should changed with new timezone America/New_York:

                      Local time: Wed 2021-04-30 02:30:39 EDT
                  Universal time: Wed 2021-04-30 06:30:39 UTC
                        RTC time: Wed 2021-04-30 06:30:39
                       Time zone: America/New_York (EDT, -0400)
       System clock synchronized: yes
systemd-timesyncd.service active: yes
                 RTC in local TZ: no


How to Change Timezone By Symlink ?

Another way to change timezone is by creating a symlink. This method is useful when your server is running older version of Ubuntu or when timedatectl command is not available. We are going to change the timezone by creating symlink /etc/localtime to the timezone in the /usr/share/zoneinfo directory.

First, you need to delete current /etc/localtime symlink or file by typing:

$ sudo rm -rf /etc/localtime

After that, add the timezone which you want to set and creating a symlink:

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

Now, if you want to verify it you can do it by listing the /etc/localtime file or run the date command:

$ date

It will show below output:

Output
Tue Apr 30 02:37:22 EDT 2021


[Need assistance in fixing firewall configuration on Ubuntu Linux Systems? We can help you. ]


Conclusion

This article covers how to change timezone in Ubuntu 18.04. If you have set up your Ubuntu system to fetch Automatic Time Zone, it will sync your system through the internet so that it will have the time zone of your closest location.

Most modern distributions such as Fedora, Debian, Ubuntu, Arch, CentOS v.7.x+, and other Unix-based systems use the timedatectl utility. This command allows you to control and edit time and date settings using the command line.


To display the current time and date information use the command:

$ timedatectl

You can set your Ubuntu system to synchronize to the NIST atomic clock:

$ timedatectl set-ntp yes

If you need to turn off NTP synchronizing to be able to adjust the time and date manually, use:

$ timedatectl set-ntp no