How to Check Timezone in Linux

In this short article, we will walk newbies through the various simple ways of checking system timezone in Linux. Time management on a Linux machine especially a production server is always an important aspect of system administration.

There are a number of time management utilities available on Linux such as date and timedatectl commands to get the current timezone of system and synchronize with a remote NTP server to enable an automatic and more accurate system time handling.

Well, let us dive into the different ways of finding out our Linux system timezone.

1. We will start by using the traditional date command to find out present timezone as follows:

$ date

Alternatively, type the command below, where %Z format prints the alphabetic timezone and %z prints the numeric timezone:

$ date +"%Z %z"
Find Linux Timezone
Find Linux Timezone

Note: There are many formats in the date man page that you can make use of, to alter the output of the date command:

$ man date

2. Next, you can likewise use timedatectl, when you run it without any options, the command displays an overview of the system including the timezone like so:

$ timedatectl

More so, try to employ a pipeline and grep command to only filter the timezone as below:

$ timedatectl | grep “Time zone”
Find Current Linux Timezone
Find Current Linux Timezone

Learn how to set timezone in Linux using timedatectl command.

3. In addition, users of Debian and its derivatives can display the content of the file /etc/timezone using cat utility to check your timezone:

$ cat /etc/timezone
Check Timezone of Linux
Check Timezone of Linux

Important: For REHL/CentOS 7 and Fedora 25-22 users, the file /etc/localtime is a symbolic link to the timezone file under the directory /usr/share/zoneinfo/.

However, you can use date or timedatectl command to display the current time and timezone as well.

To change the timezone, create the symbolic link /etc/localtime to the appropriate timezone under /usr/share/zoneinfo/:

$ sudo ln  -sf /usr/share/zoneinfo/zoneinfo /etc/localtime

The flag -s enables creation of a symbolic link, otherwise a hard link is created by default and -f removes an existing destination file, which in this case is /etc/localtime.

For example, to change the timezone to Africa/Nairobi, issue the command below:

$ sudo ln -sf /usr/share/zoneinfo/Africa/Nairobi /etc/localtime

That’s all! Do not forget to share you thoughts about the article by means of the feedback form below. Importantly, you should look through this time management guide for Linux to get more insight into handling time on your system, it has simple and easy-to-follow examples.

Lastly, always remember to stay tunned to Tecmint for the latest and interesting Linux stuff.

If you read this far, tweet to the author to show them you care. Tweet a thanks
Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

15 thoughts on “How to Check Timezone in Linux”

  1. Any suggestion where should I check further? All settings seem correct? It looks like there is an extra character at the end of America/Chicago.

    ERROR:
    tzone_read_system: no match found for America/Chicago^?

    Here are my current settings

    [root@backup etc]# timedatectl
          Local time: Thu 2020-04-23 11:28:51 CDT
      Universal time: Thu 2020-04-23 16:28:51 UTC
            RTC time: Thu 2020-04-23 16:28:51
           Time zone: America/Chicago (CDT, -0500)
         NTP enabled: no
    NTP synchronized: yes
     RTC in local TZ: no
          DST active: yes
     Last DST change: DST began at
                      Sun 2020-03-08 01:59:59 CST
                      Sun 2020-03-08 03:00:00 CDT
     Next DST change: DST ends (the clock jumps one hour backwards) at
                      Sun 2020-11-01 01:59:59 CDT
                      Sun 2020-11-01 01:00:00 CST
    [root@backup etc]# 
    
    [root@triadbackup etc]# ls -ltr /etc/localtime
    lrwxrwxrwx. 1 root root 37 Mar 26 12:20 /etc/localtime -> ../usr/share/zoneinfo/America/Chicago
    [root@backup etc]# 
    [root@backup etc]# timedatectl | grep local
     RTC in local TZ: no
    [root@backup etc]# 
    [root@backup etc]# timedatectl list-timezones | grep Chicago
    America/Chicago
    [root@backup etc]# 
    [root@triadbackup etc]# date
    Thu Apr 23 11:34:36 CDT 2020
    [root@backup etc]#
    
    Reply
      • CentOS Linux release 7.7.1908 (Core).

        We just fixed the issue by “rerunning” the timezone. The log showed bad characters at the end, America/Chicago^? (^?).

        We ran tzselect and then chose options 2, 49, 11 for Chicago. Gracefully rebooted the server “shutdown -r now

        Thank you, Aaron, for your reply.

        Reply
  2. The formatting on your "%Z %z" example is a bit off. When your text is displayed, the usual, plain double quotes (") are replaced with “pretty” ones (”). When I pasted your example into my terminal, I only received errors. You should format your example as:

    date '+%Z %z'
    

    (Here’s hoping that when I post this comment, the website doesn’t replace my simple quotes with pretty ones!)

    Reply
    • Yes, my simple quotes were replaced with pretty ones. That’s not good for displaying things on a technical website. You should see about disabling that feature.

      Reply
  3. On Centos 7 there’s no “clock” under /etc/sysconfig. And neither is there a /etc/timezone, which, from what you’re saying, should exist on most or all linux distributions.

    Reply
      • Indeed, but /etc/localtime is not plain text, it is a binary file. To be more specific, it is a symbolic link to a binary file found in /usr/share/zoneinfo.

        So you couldn’t simply grep it in Centos :) You simply create a symbolic link to whatever timezone you want and then you can use date or timedatectl to see the current clock.

        Reply
        • @lethargos

          Once again, many thanks for the vital insight into checking and managing timezone on RHEL/CentOS 7, this will be very helpful to users out there.

          Reply
          • You’re welcome, but shouldn’t you update the article accordingly, so that other users actually know? There’s a higher chance that they’ll read the article than the comments.

          • @lethargos

            As you usefully suggested, we have updated the article to include the correct way of setting and checking timezone in REHL 7/CentOS 7/Fedora 25-22 systems.

            Many thanks for always following us and offering constructive thoughts.

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.