How to Change Time Zone in Linux
Selection of the standard and precise timezone is crucial for evaluation and execution of many tasks and processes running on a Linux instance. In our day to day life, we come across certain circumstances where the need of changing and setting up the different timezone on Linux system originates consistently.
This tutorial contains the detailed instructions for changing the timezone on various distributions of Linux.
Instructions for changing the time zone on Centos.
Instruction for changing the time zone on Ubuntu.
Instructions for changing the time zone on Amazon ec2 instances.
Location for Local Time File
Linux system fetches the local time and timezone information from file “/etc/localtime”
Directory Containing the Time Zone in Linux
Directory “/usr/share/zoneinfo” contains the list of time zone data files.
Listing the directory at that location will provide us with a list of various time zones available in Linux. You will also find some directories inside this location. These directories further contain the zone files for different cities.
Changing the Time Zone in Linux
In this tutorial, we are going the change the timezone of our machine to Calcutta city located in India, Continent is Asia. Basically, we are going to change our machine time to IST.
To change the time zone in Linux we can use any of one method listed below.
1. We can create a soft link to file “/etc/localtime” and link it to the required zone file.
ln -sf /usr/share/zoneinfo/Asia/Calcutta /etc/localtime
For non ROOT users, run command with sudo privileges.
sudo ln -sf /usr/share/zoneinfo/Asia/Calcutta /etc/localtime
Successful execution of above command will change the timezone to IST.
2. We can copy the data of required zone file to “/etc/localtime” file.
cp /usr/share/zoneinfo/Asia/Calcutta /etc/localtime
For non ROOT users, run command with sudo privileges.
sudo cp /usr/share/zoneinfo/Asia/Calcutta /etc/localtime
Successful execution of this file will also change the timezone to the required one.
This brings up an end to the tutorial. Hope you guys will find it useful. For any queries, do not hesitate to ask them in the comments section. Keep sharing and supporting the blog. Stay tuned for future updates. Thanks!
Excellent blog post. I absolutely appreciate this website.
Keep writing!