How to Check and Set Timezone in Ubuntu
To Check and Set Timezone in Ubuntu
In this article we going to show how to check and set Timezone in simple way on Ubuntu machine. It is necessary to ensure and maintain an accurate log time-stamps in distributing systems.
To Check Timezone
First try a traditional command " date" to check the Timezone.
root@linuxhelp:~# date
Tue Nov 15 19:50:21 IST 2016
Use another command ' timedatectl' .
root@linuxhelp:~# timedatectl
Local time: Tue 2016-11-15 19:51:23 IST
Universal time: Tue 2016-11-15 14:21:23 UTC
RTC time: Tue 2016-11-15 14:21:23
Time zone: Asia/Kolkata (IST, +0530)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no
You can also use timedatectl with grep command.
root@linuxhelp:~# timedatectl | grep " Time zone"
Time zone: Asia/Kolkata (IST, +0530)
Another simple method to check the timezone is using " cat" command.
root@linuxhelp:~# cat /etc/timezone
Asia/Kolkata
The strings command also displays the timezone.
root@linuxhelp:~# strings /etc/localtime | tail -n 1
IST-5:30
Move to the zoneinfo location and execute below command to check timezone in different way.
root@linuxhelp:~# cd /usr/share/zoneinfo root@linuxhelp:/usr/share/zoneinfo# find * -type f -exec sh -c " diff -q /etc/localtime ' {}' > /dev/null & & echo {}" Asia/Calcutta
To Set Timezone
Run the below command to set the time zone.
root@linuxhelp:~# dpkg-reconfigure tzdata
Select your continent.
Select your city.
After selecting the timezone, it displays the output as shown below,
Current default time zone: ' Asia/Kolkata' Local time is now: Tue Nov 15 19:58:25 IST 2016. Universal Time is now: Tue Nov 15 14:28:25 UTC 2016.
Also use timedatectl command to set timezone.
root@linuxhelp:~# timedatectl set-timezone Asia/Kolkata
Once the timezone is set, check and verify your settings with the following command.
root@linuxhelp:~# timedatectl
Local time: Tue 2016-11-15 20:00:07 IST
Universal time: Tue 2016-11-15 14:30:07 UTC
RTC time: Tue 2016-11-15 14:30:08
Time zone: Asia/Kolkata (IST, +0530)
Network time on: yes
NTP synchronized: yes
RTC in local TZ: no
Comments ( 0 )
No comments available