Get the App
SLTechnology News&Howtos  ›  Servers  › 

How does linux query the time zone

Shulou Source: shulou.com Published: 2022-05-31 11:04:25 10月01日 Update

This article mainly explains "how to query the time zone in linux". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to query the time zone by linux"!

Methods: 1, using date command, syntax is "date +" Z% z ""; 2, using timedatectl command, syntax is "timedatectl | grep" Time zone ""; 3, using cat command, syntax is "cat / etc/timezone".

The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

How does linux query the time zone?

1. Let's start with using the traditional date command

Take a look at our current time zone using the following command:

$date

Alternatively, you can use the following command. Where the% Z format can output the time zone in the form of characters, and the% z can output the time zone in numeric form:

$date + "Z z"

God teaches you to check your time zone in Linux. God teaches you to check your time zone in Linux.

Note: date's man page contains many output formats that you can use to replace the output of your date command:

$man date

2. Next, you can also use the timedatectl command

When you run it without any parameters, this command outputs an overview of the system time, including the current time zone, as shown in the following figure:

$timedatectl

You can then provide a pipe in the command and use the grep command to filter out only the time zone information as follows:

$timedatectl | grep "Time zone"

God teaches you to check your time zone in Linux. God teaches you to check your time zone in Linux.

Similarly, we can learn how to use timedatectl to set the Linux time zone.

3. Further, display the contents of the file / etc/timezone

Use the cat tool to display the contents of the file / etc/timezone to view your time zone:

$cat / etc/timezone

For RHEL/CentOS/Fedora users, here is another command that has the same effect:

Grep ZONE / etc/sysconfig/clock so far, I believe you have a better understanding of "how to query the time zone in linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Time zone command query content output god grammar learning form file method format system faceted practical deeper next following figure tradition information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Apple Huawei MariaDB Shulou Information