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. This tutorial will describe multiple ways to change timezone on Ubuntu 18.04 system.
Make sure that you are logged in as a user account with sudo privileges.
Get Current Timezone
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:
It will display output as below:
Local time: Tue 2019-04-30 11:57:15 IST Universal time: Tue 2019-04-30 06:27:15 UTC RTC time: Tue 2019-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 of Ubuntu
- /usr/share/zoneinfo/ – Timezone name wise files are stored in this directory. For example, the file
/usr/share/zoneinfo/America/New_Yorkrepresents time zone for New York.
- /etc/localtime – This is a symlink to the file localtime located in
Change Timezone in Ubuntu
At first, you should know long name for timezone which you want to set. To get the list of all available timezones run below command:
It will show output like below:
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
It should changed with new timezone
Local time: Wed 2019-04-30 02:30:39 EDT Universal time: Wed 2019-04-30 06:30:39 UTC RTC time: Wed 2019-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
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 not have
timedatectl command is available. We are going to change the timezone by creating symlink
/etc/localtime to the timezone in the
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:
It will show below output:
Tue Apr 30 02:37:22 EDT 2019
Finally, you have learned how to change timezone in Ubuntu 18.04. If you have any question you can leave comment below.