From 7faf3872ae02996638ceb5f24be1c76e3d1ea989 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Tue, 10 Jan 2023 13:03:17 +0800 Subject: [PATCH] RP @geekpi https://linux.cn/article-15430-1.html --- ... Command in Linux Explanation with Examples.md | 59 ++++++++++--------- 1 file changed, 32 insertions(+), 27 deletions(-) rename {translated/tech => published}/20230102.1 ⭐️ who Command in Linux Explanation with Examples.md (54%) diff --git a/translated/tech/20230102.1 ⭐️ who Command in Linux Explanation with Examples.md b/published/20230102.1 ⭐️ who Command in Linux Explanation with Examples.md similarity index 54% rename from translated/tech/20230102.1 ⭐️ who Command in Linux Explanation with Examples.md rename to published/20230102.1 ⭐️ who Command in Linux Explanation with Examples.md index d2097e7d35..8dfae90cf2 100644 --- a/translated/tech/20230102.1 ⭐️ who Command in Linux Explanation with Examples.md +++ b/published/20230102.1 ⭐️ who Command in Linux Explanation with Examples.md @@ -3,24 +3,26 @@ [#]: author: "Arindam https://www.debugpoint.com/author/admin1/" [#]: collector: "lkxed" [#]: translator: "geekpi" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-15430-1.html" -Linux 中的 who 命令:解释与示例 +who 命令的解释与示例 ====== -**这里是一个关于理解 Linux 中 who 命令的初学者指南,并有几个例子。** +![][0] -_这篇文章是 [Linux 命令][1]学习系列的一部分。_ +> 这里是一个关于理解 Linux 中 who 命令的初学者指南,并带有几个例子。 + +这篇文章是 [Linux 命令][1]学习系列的一部分。 ### who 命令 -Linux中的 “who” 命令用于显示当前登录到系统中的用户的信息。它显示用户的登录名,用户登录的终端,用户登录的时间,以及远程主机名(如果有)。 +Linux 中的 `who` 命令用于显示当前登录到系统中的用户的信息。它显示用户的登录名,用户登录的终端,用户登录的时间,以及远程主机名(如果有)。 #### 语法 -下面是 “who” 命令的基本语法: +下面是 `who` 命令的基本语法: ``` who [OPTION]... [ FILE | ARG1 ARG2 ] @@ -28,13 +30,13 @@ who [OPTION]... [ FILE | ARG1 ARG2 ] ### 各种 who 命令和开关的例子 -默认情况下,“who” 读取文件 `/var/run/utmp`,其中包含当前登录的用户的信息。如果没有指定选项,它会显示每个用户的登录名、终端和登录时间。 +默认情况下,`who` 读取文件 `/var/run/utmp`,其中包含当前登录的用户的信息。如果没有指定选项,它会显示每个用户的登录名、终端和登录时间。 ``` who ``` -它给出了以下输出。你可以看到它显示了登录名是 debugpoint,终端ID tty2 和登录的日期和时间。 +它给出了以下输出。你可以看到它显示了登录名是 `debugpoint`,终端 ID `tty2` 和登录的日期和时间。 ``` debugpoint tty2 2023-01-01 11:22 (tty2) @@ -42,10 +44,11 @@ debugpoint tty2 2023-01-01 11:22 (tty2) ![who 命令 - 默认示例][2] -然而,如果你在虚拟机中运行上述命令,你应该看到同样的情况,但终端 ID 将是 x11 服务器的显示名称,即:0。 +然而,如果你在虚拟机中运行上述命令,你应该看到同样的情况,但终端 ID 将是 x11 服务器的显示名称,即 `:0`。 ``` -❯ whodebugpoint :0 2023-01-01 23:36 (:0) +❯ who +debugpoint :0 2023-01-01 23:36 (:0) ``` 要显示当前用户的用户名和信息,使用下面的方法: @@ -54,19 +57,22 @@ debugpoint tty2 2023-01-01 11:22 (tty2) whoami ``` -使用 -b 选项查看最后一次系统启动时间: +使用 `-b` 选项查看最后一次系统启动时间: ``` -❯ who -bsystem boot 2023-01-01 23:36 +❯ who -b +system boot 2023-01-01 23:36 ``` 显示当前系统中登录的用户数: ``` -❯ who -qdebugpointusers=1 +❯ who -q +debugpoint +users=1 ``` -所有上述命令与 -H 选项配对时,你会有一个更好的含标题行的信息,如下所示: +所有上述命令与 `-H` 选项配对时,你会有一个更好的含标题行的信息,如下所示: ``` who -H @@ -75,7 +81,7 @@ NAME LINE TIME COMMENT debugpoint tty2 2023-01-01 11:22 (tty2) ``` -如果你想在Linux中显示与who命令有关的所有信息,请使用选项-a: +如果你想在 Linux 中显示与 `who` 命令有关的所有信息,请使用选项 `-a`: ``` who -aH @@ -86,7 +92,7 @@ run-level 5 2023-01-01 11:19 debugpoint + tty2 2023-01-01 11:22 13:26 2042 (tty2) ``` -像往常一样,你可以使用下面的重定向将 who 命令的输出保存到任何文件: +像往常一样,你可以使用下面的重定向将 `who` 命令的输出保存到任何文件: ``` who > user_details.txt @@ -94,9 +100,9 @@ who > user_details.txt #### who 命令选项的例子总结 -下面是一些 who 命令的例子和它们的解释: +下面是一些 `who` 命令的例子和它们的解释: -下面是一些可以与 “who” 命令一起使用的选项: +下面是一些可以与 `who` 命令一起使用的选项: - `-a`: 显示每个用户的主机名、登录时间和进程 - `-b`: 显示上次系统启动的时间 @@ -105,14 +111,12 @@ who > user_details.txt - `-l`: 显示长格式的登录进程 - `-m`: 只显示在 `ARG1 ARG2` 指定的终端上登录的用户的名字和行。 - `-q`: 显示已登录用户的数量 -- `-u`: 显示拥有未分离进程的用户的信息 +- `-u`: 显示拥有未脱离进程的用户的信息 - `-w`: 显示已经登录的用户信息,格式与 utmp 文件相同 -### 结尾说明 +### 总结 -我希望这篇文章能够帮助你了解 who 命令及其基本原理。你也可以阅读 [who 手册页][3]来了解更多。如果你有任何问题,请告诉我。 - -**本文是 [Linux 命令][1]学习系列的一部分**。 +我希望这篇文章能够帮助你了解 `who` 命令及其基本原理。你也可以阅读 [who 手册页][3]来了解更多。如果你有任何问题,请告诉我。 -------------------------------------------------------------------------------- @@ -120,8 +124,8 @@ via: https://www.debugpoint.com/who-command-linux/ 作者:[Arindam][a] 选题:[lkxed][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -130,3 +134,4 @@ via: https://www.debugpoint.com/who-command-linux/ [1]: https://www.debugpoint.com/category/linux-commands [2]: https://www.debugpoint.com/wp-content/uploads/2023/01/who-command-default-example.jpg [3]: https://man7.org/linux/man-pages/man1/who.1.html +[0]: https://img.linux.net.cn/data/attachment/album/202301/10/130213zb6odhv8gl8cvxvo.jpg \ No newline at end of file