Tuesday 14 June 2016

Changing The Time Zone In Linux (Command Line)

There are several different ways to manage time in Linux. This quick tip will show you how to quickly change the local time to the correct time zone for the server. In this Linux tip I’ll show you how to change the localtime to your (or a) current time zone.
Location of the local time file
Linux looks at /etc/localtime to determine the current time of your machine. This can either be a symbolic link to the correct time zone or a direct copy of the time zone file.


Timezone files are located in /usr/share/zoneinfo/
For this tip we will assume your server is located in Asia and will be under the Kolkata  zone.
I change the Linux time zone by copying or making a symbolic link to from /usr/share/zoneinfo/Asia/Kolkata to /etc/localtime
For RHEL 6
1) cp /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
2) ln -s /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
For RHEL 7 & Ubuntu 14.04
1) timedatectl set-timezone Asia/Kolkata
Arun
 

1 comment: