A time zone refers to the local time of any region or a country. Generally each country uses one time zone but few of the countries shares multiple time zones due to its geological areas.
It is always recommended to set a correct time zone on your server during initial setup. Most of applications are build to use system time zone and manage their data accordantly. In that situation your system must have correct time zone configured.
This tutorial will describe you to how to set or change time zone on Ubuntu 20.04 Linux systems.
Check Current Timezone
Login to your Ubuntu system and open a terminal (CTRL+ALT+T). Then just type “date” command to view the current date of system including active time zone on Ubuntu system.
date
Tue Dec 15 14:21:23 IST 2020
The above command shows that this system is running in UTC timezone.
You can also refer to the timedatectl command to view the details output of the current system time, timezone and many other details.
timedatectl
Local time: Tue 2020-12-15 14:21:35 IST Universal time: Tue 2020-12-15 08:51:35 UTC RTC time: Tue 2020-12-15 08:50:17 Time zone: Asia/Kolkata (IST, +0530) Network time on: yes NTP synchronized: yes RTC in local TZ: no
Change Timezone in Ubuntu 20.04
The Ubuntu systems keeps time zone configuration files under the /usr/share/zoneinfo directory. There you can find all the available time zone.
You can choose one of the below methods to change Linux system time zone via command line.
Option 1 – Using timedatectl
Use of timedatectl command is the proffered way to set or change time zone on a Linux system. First find all the available timezones on your system.
timedatectl list-timezones
Search for the required time zone name in above command. Next use one of the following command to set new time zone on your system.
sudo timedatectl set-timezone "America/New_York"
Below is some more frequently used Timezones examples.
## Set timezone to "America/New_York" sudo timedatectl set-timezone "America/New_York"
## Set timezone to "Europe/London" sudo timedatectl set-timezone "Europe/London"
## Set timezone to "EST" sudo timedatectl set-timezone "EST"
## Set timezone to "UTC" sudo timedatectl set-timezone "UTC"
## Set timezone to "Asia/Kolkata" sudo timedatectl set-timezone "Asia/Kolkata"
Option 2 – Using /etc/localtime
You can also change the system time by changing the symbolic link of /etc/localtime file on Linux systems. You just need to search for the correct time zone files under /usr/share/zoneinfo directory.
First rename of remove the current file:
mv /etc/localtime /etc/localtime-backup
Then change the symbolic link of file to the correct time zone configuration file:
ln -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
The system will automatically adjust the new time based on new time zone set on system. You can again run “timedatectl” command to confirm time zone is updated correctly.
Conclusion
This tutorial helped you to check and change time zone on Ubuntu 20.04 Linux system.