God teaches you to check your time zone in Linux

In this short article, we will briefly introduce you to several simple ways to check the system time zone under Linux . Time management skills in Linux machines, especially production servers, are an extremely important aspect in system administration.

Linux includes a variety of time management tools available, such as date or timedatectlcommands, you can use them to obtain the current system time zone, and you can also synchronize the system time with an NTP server for automatic and more accurate time management.

Alright, let's take a look at a few different ways of checking our Linux system's time zone.

1. We start by using the traditional date command

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

$ date

Alternatively, you can also use the command below. Among them, the %Z format can output the time zone in character form, and %z outputs the time zone in numerical form:

$ date +”%Z %z”

Check Linux time zone

Note: The date man page contains a number of 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 arguments, this command outputs an overview of the system time, including the current time zone, as shown below:

$ timedatectl

Then, you can provide a pipeline in the command and use the grep command to filter out only the time zone information like this:

$ timedatectl | grep “Time zone”

View current Linux time zone

Likewise, 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 see your time zone:

$ cat /etc/timezone

Check Time Zone in Linux

对于 RHEL/CentOS/Fedora 用户,这里还有一条可以起到同样效果的命令:

$ grep ZONE /etc/sysconfig/clock

就这些了!别忘了在下面的反馈栏中分享你对于这篇文章中的看法。重要的是:你应该通过这篇 Linux 时区管理指南来学习更多系统时间管理的知识,因为它含有很多易于操作的实例。

Guess you like

Origin blog.csdn.net/u014389734/article/details/129372654