mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
Merge pull request #4667 from StdioA/master
Finish 20161114 How to Check Timezone in Linux
This commit is contained in:
commit
f9c59bbaea
@ -1,90 +0,0 @@
|
||||
Translating by StdioA
|
||||
|
||||
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 timedatectlcommands to get the current timezone of system and [synchronize with a remote NTP server][1] 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](http://www.tecmint.com/wp-content/uploads/2016/10/Find-Linux-Timezone.png)
|
||||
][2]
|
||||
|
||||
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][3] to only filter the timezone as below:
|
||||
|
||||
```
|
||||
$ timedatectl | grep “Time zone”
|
||||
```
|
||||
[
|
||||
![Find Current Linux Timezone](http://www.tecmint.com/wp-content/uploads/2016/10/Find-Current-Linux-Timezone.png)
|
||||
][4]
|
||||
|
||||
Find Current Linux Timezone
|
||||
|
||||
Learn how to [set timezone in Linux using timedatectl][5] command.
|
||||
|
||||
3. In addition, display the content of the file `/etc/timezone` using [cat utility][6] to check your timezone:
|
||||
|
||||
```
|
||||
$ cat /etc/timezone
|
||||
```
|
||||
[
|
||||
![Check Timezone of Linux](http://www.tecmint.com/wp-content/uploads/2016/10/Check-Timezone-of-Linux.png)
|
||||
][7]
|
||||
|
||||
Check Timezone of Linux
|
||||
|
||||
For REHL/CentOS/Fedora users, here is one more command for the same purpose:
|
||||
|
||||
```
|
||||
$ grep ZONE /etc/sysconfig/clock
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/check-linux-timezone
|
||||
|
||||
作者:[Aaron Kili ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/install-ntp-server-in-centos/
|
||||
[2]:http://www.tecmint.com/wp-content/uploads/2016/10/Find-Linux-Timezone.png
|
||||
[3]:http://www.tecmint.com/12-practical-examples-of-linux-grep-command/
|
||||
[4]:http://www.tecmint.com/wp-content/uploads/2016/10/Find-Current-Linux-Timezone.png
|
||||
[5]:http://www.tecmint.com/set-time-timezone-and-synchronize-time-using-timedatectl-command/
|
||||
[6]:http://www.tecmint.com/13-basic-cat-command-examples-in-linux/
|
||||
[7]:http://www.tecmint.com/wp-content/uploads/2016/10/Check-Timezone-of-Linux.png
|
82
translated/tech/20161114 How to Check Timezone in Linux.md
Normal file
82
translated/tech/20161114 How to Check Timezone in Linux.md
Normal file
@ -0,0 +1,82 @@
|
||||
在 Linux 中查看你的时区
|
||||
============================================================
|
||||
|
||||
在这篇短文中,我们将向你简单介绍几种 Linux 下查看系统时区的简单方法。在 Linux 机器中,尤其是生产服务器上的时间管理技能,是在系统管理中一个极其重要的方面。
|
||||
|
||||
Linux 包含多种可用的时间管理工具,比如 `date` 或 `timedatectlcommands`,你可以用它们来获取当前系统时区,也可以[将系统时间与 NTP 服务器同步][1],来自动地、更精确地进行时间管理。
|
||||
|
||||
好,我们一起来看几种查看我们的 Linux 系统时区的不用方法。
|
||||
|
||||
1. 我们从使用传统的 `date` 命令开始。使用下面的命令,来看一看我们的当前时区:
|
||||
|
||||
```
|
||||
$ date
|
||||
```
|
||||
|
||||
或者,你也可以使用下面的命令。其中 `%Z` 格式可以输出字符形式的时区,而 `%z` 输出数字形式的时区:
|
||||
|
||||
```
|
||||
$ date +”%Z %z”
|
||||
```
|
||||
[![Find Linux Timezone](http://www.tecmint.com/wp-content/uploads/2016/10/Find-Linux-Timezone.png)][2]
|
||||
|
||||
查看 Linux 时区
|
||||
|
||||
注意:`date` 的手册页中包含很多输出格式,你可以利用它们,来替换你的 `date` 命令的输出内容:
|
||||
|
||||
```
|
||||
$ man date
|
||||
```
|
||||
|
||||
2. 接下来,你同样可以用 `timedatectl` 命令。当你不带任何参数运行它时,这条命令可以像下图一样,输出系统时间概览,其中包含当前时区:
|
||||
|
||||
```
|
||||
$ timedatectl
|
||||
```
|
||||
|
||||
然后,你可以在命令中提供一条管道,然后用 [grep 命令][3] 来像下面一样,只过滤出时区信息:
|
||||
|
||||
```
|
||||
$ timedatectl | grep “Time zone”
|
||||
```
|
||||
[![Find Current Linux Timezone](http://www.tecmint.com/wp-content/uploads/2016/10/Find-Current-Linux-Timezone.png)][4]
|
||||
|
||||
查看当前 Linux 时区
|
||||
|
||||
同样,我们可以学习如何使用 timedatectl 来[设置 Linux 时区][5]。
|
||||
|
||||
3. 进一步,使用 [cat 工具][6]显示文件 `/etc/timezone` 的内容,来查看你的时区:
|
||||
|
||||
```
|
||||
$ cat /etc/timezone
|
||||
```
|
||||
[![Check Timezone of Linux](http://www.tecmint.com/wp-content/uploads/2016/10/Check-Timezone-of-Linux.png)][7]
|
||||
|
||||
在 Linux 中查看时区
|
||||
|
||||
对于 RHEL/CentOS/Fedora 用户,这里还有一条可以起到同样效果的命令:
|
||||
|
||||
```
|
||||
$ grep ZONE /etc/sysconfig/clock
|
||||
```
|
||||
|
||||
就这些了!别忘了在下面的反馈栏中分享你对于这篇文章中的看法。重要的是:你应该通过这篇 Linux 时区管理指南来学习更多系统时间管理的知识,因为它含有很多易于操作的实例。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/check-linux-timezone
|
||||
|
||||
作者:[Aaron Kili][a]
|
||||
译者:[StdioA](https://github.com/StdioA)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/install-ntp-server-in-centos/
|
||||
[2]:http://www.tecmint.com/wp-content/uploads/2016/10/Find-Linux-Timezone.png
|
||||
[3]:http://www.tecmint.com/12-practical-examples-of-linux-grep-command/
|
||||
[4]:http://www.tecmint.com/wp-content/uploads/2016/10/Find-Current-Linux-Timezone.png
|
||||
[5]:http://www.tecmint.com/set-time-timezone-and-synchronize-time-using-timedatectl-command/
|
||||
[6]:http://www.tecmint.com/13-basic-cat-command-examples-in-linux/
|
||||
[7]:http://www.tecmint.com/wp-content/uploads/2016/10/Check-Timezone-of-Linux.png
|
Loading…
Reference in New Issue
Block a user