In this article, I will explain how to check timezone in Linux using 4 Easy Methods. System time is usually defined by timezone. You might be aware that entire globe is divided into multiple timezones which determines its local time. You can see the use of same timezone in your System for various purposes. Timezone concept is more important when we are talking about a Cluster setup who's nodes are basically lies on two different geographical region. It is important to sync the timezone between the nodes to form a Cluster. Hence I will try to explain different methods through examples using which one can check the timezone in their Linux Based Systems.
How to Check timezone in Linux
Method 1: Check timezone in Linux using timedatectl command
You can check timezone in Linux by simply running
timedatectl command and checking the time zone section of the output as shown below.
[root@localhost ~]# timedatectl Local time: Mon 2020-05-18 00:34:31 EDT Universal time: Mon 2020-05-18 04:34:31 UTC RTC time: Sat 2020-05-16 12:01:40 Time zone: America/New_York (EDT, -0400) NTP enabled: yes NTP synchronized: no RTC in local TZ: no DST active: yes Last DST change: DST began at Sun 2020-03-08 01:59:59 EST Sun 2020-03-08 03:00:00 EDT Next DST change: DST ends (the clock jumps one hour backwards) at Sun 2020-11-01 01:59:59 EDT Sun 2020-11-01 01:00:00 EST
Instead of checking the entire output you can also just grep the zone keyword from
timedatectl command output and get the timezone as shown below.
[root@localhost ~]# timedatectl | grep -i zone Time zone: America/New_York (EDT, -0400)
You can also check the list of timezones using
timedatectl list-timezones command as shown in below output.
[root@localhost ~]# timedatectl list-timezones Africa/Abidjan Africa/Accra Africa/Addis_Ababa Africa/Algiers Africa/Asmara Africa/Bamako Africa/Bangui Africa/Banjul Africa/Bissau Africa/Blantyre Africa/Brazzaville Africa/Bujumbura Africa/Cairo Africa/Casablanca Africa/Ceuta Africa/Conakry Africa/Dakar Africa/Dar_es_Salaam Africa/Djibouti Africa/Douala Africa/El_Aaiun Africa/Freetown Africa/Gaborone Africa/Harare Africa/Johannesburg Africa/Juba Africa/Kampala Africa/Khartoum Africa/Kigali Africa/Kinshasa Africa/Lagos Africa/Libreville Africa/Lome Africa/Luanda Africa/Lubumbashi Africa/Lusaka Africa/Malabo Africa/Maputo Africa/Maseru Africa/Mbabane Africa/Mogadishu Africa/Monrovia
rootuser to run all the below commands.You can use any user with
sudoaccess to run all these commands.For more information Please check Step by Step: How to Add User to Sudoers to provide
sudoaccess to User.
Method 2: Check timezone in Linux using date command
You can also check the timezone by simply running
date command as shown below.
[root@localhost ~]# date Mon May 18 00:42:20 EDT 2020
In the above output you can see current date and time but if you are interested only in checking the timezone then you can use
date "+%Z" command as shown below.
[root@localhost ~]# date "+%Z" EDT
You can also check the timezone in numeric form by using below
[root@localhost ~]# date "+%z%Z" -0400EDT
Method 3: Check timezone from /etc/timezone File(On Ubuntu/Debian Based Systems)
In Ubuntu based Systems, you can check the timezone from
/etc/timezone file as shown below. As you can from below output, current timezone is set to
root@localhost:~# cat /etc/timezone Asia/Kolkata
Method 4: Check timezone using Geolocation
You can use
curl command to check the timezone using Geolocation as shown below. Please note that running below command command would require an active internet connection in your server.
[root@localhost ~]# curl https://ipapi.co/timezone;echo Asia/Kolkata