How to Change Time Zone in Linux

In this blog post, we will show you how to change time zone in linux system.

In Linux system, time zone points to local time of region or county. When time zone is set in linux then it’s time automatically set according to region or country. It is always recommended to set correct time zone according to the geographical location of the system.

Time zone plays an important role in linux system when run cron jobs and database transactions. There are two different ways to change time zone.

Change Time Zone in Linux using timedatectl

Modern linux systems have timedatectl command to manage time and date based on the time zone. To check the current time zone, date and time in linux system, run

$ timedatectl

Output

timedatectl-command-output

Let’s assume, we want to set time in IST format. So first we have to look for the time zone for IST, run following command to search ‘asia/kolkata’ time zone.

$ timedatectl list-timezones | grep -i 'asia/kolkata'
Asia/Kolkata
$

Run following timedatectl command to set time zone as ‘Asia/kolkata

$ sudo timedatectl set-timezone Asia/Kolkata

Verify date, time and time zone

$ date
$ timedatectl

Output of above commands would like below,

Change Time Zone in Linux

Perfect, above confirms that date and time zone has been updated.

Change Time zone in Linux using File

When time zone is set in linux then it actually creates a soft link of zone file under directory ‘/usr/share/zoneinfo/’ to ‘/etc/localtime’. So to set the time zone manually, refer the following steps.

Let’s assume we want to change the time zone from ‘Asia/Kolkata’ to ‘Europe/London’.

$ date
Sun Nov 21 11:02:16 IST 2021
$

Delete /etc/localtime file using rm command

$ sudo rm -f /etc/localtime

Create a soft link of zone file ‘/usr/share/zoneinfo/Europe/London’ to ‘/etc/localtime

$ sudo ln -s /usr/share/zoneinfo/Europe/London /etc/localtime

Verify the time using date command

$ date
Sun Nov 21 05:32:33 GMT 2021
$

Output of above command:

Change Time zone in Linux using File

Great, above confirms that time has been updated as per ‘Europe/London’ time zone. That’s all from this post. Please do share your queries and feedback in below comments section.

Also Read: How to Sync Time on Linux System using Chrony

Leave a Comment

one × 2 =