How to check computer's timezone through Terminal?

55,475

Use:

timedatectl status | grep "Time zone"

Without the grep you get a lot more of information.

As pointed out by @Christian Ulbrich in comment the wording for timezone seems to change depending on which version of timaedatectl or systemd you are using (on 14.04.5 it seems to be Timezone written in one word), so to make sure you get the proper output, you can run the above command without piping through grep to make sure you grep the right thing.

Here an example output of the above timedatectl status command on 18.04 without piping it through to grep:

enter image description here

Share:
55,475

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    I am writing a bash script which at some point needs to determine a user's timezone, so how exactly can I check the timezone in Terminal? I would like to be able to get output in terms of GMT and UTC. Though if I can get the output in terms of any others then a list of those and how to get them would be nice. I am running Ubuntu GNOME 15.10 with GNOME 3.18.

  • aliasav
    aliasav almost 6 years
    small edit: you might want to just grep "zone", since Timezone is treated as one word sometimes
  • Videonauth
    Videonauth almost 6 years
    In which language this is written in one word in this case?
  • aliasav
    aliasav almost 6 years
    on Ubuntu, timedatectl show timezone as one word
  • Videonauth
    Videonauth almost 6 years
    Then i must be on some special Ubuntu maybe, above you can see the output of timedatectl without the grep on Ubuntu 18.04, and it was the same on 16.04 which I had installed the time I wrote this answer. needless to say that it was the same on 16.10, 17.04 and 17.10 before I installed bionic. Even without the status parameter timedatectl returns me the same output.
  • aliasav
    aliasav over 5 years
    Ah okay, might be different package versions also. Maybe you'd be better off grepping a case insensitive "timezone" or "time zone" just to be sure.
  • Christian Ulbrich
    Christian Ulbrich over 5 years
    @Videonauth On Ubuntu 14.04.5 LTS it is indeed Timezone and thus grep "Time zone" does not work. Looks like it is depending on the version of Systemd used.
  • Videonauth
    Videonauth over 5 years
    @ChristianUlbrich Thank you. will change my answer accordingly when I am at my PC again.