`who mom likes` 是真正的 linux 命令吗?

spu*_*der 33 who whoami

我偶然发现了一个提到以下命令的博客。

who mom likes
Run Code Online (Sandbox Code Playgroud)

它似乎相当于

who am i 
Run Code Online (Sandbox Code Playgroud)

作者警告永远不要在命令行中输入以下内容(我怀疑他是在开玩笑)

who mom hates
Run Code Online (Sandbox Code Playgroud)

没有关于该mom命令的任何记录。它有什么作用?

slm*_*slm 33

是的,这是一个笑话,由who命令的开发人员包含在其中。参见手册页who

摘抄

如果未指定 FILE,请使用 /var/run/utmp。/var/log/wtmp 作为 FILE 很常见。如果给定 ARG1 ARG2,则假定 -m:“我是我”或“妈妈喜欢”是常见的。

此 U&L 问答题为:什么是“非选项参数”?解释了手册页中的一些术语,我的回答还涵盖了who .. .... 命令。

细节

am Ior真的没有什么特别之处am i。该who命令旨在为任何 2 个参数返回相同的结果。实际上它的行为就像你用它的-m开关调用它一样。

   -m     only hostname and user associated with stdin
Run Code Online (Sandbox Code Playgroud)

例子

$ who -m
saml     pts/1        2014-01-06 09:44 (:0)
$ who likes candy
saml     pts/1        2014-01-06 09:44 (:0)
$ who eats cookies
saml     pts/1        2014-01-06 09:44 (:0)
$ who blah blah
saml     pts/1        2014-01-06 09:44 (:0)
Run Code Online (Sandbox Code Playgroud)

其他实现

如果您查看传家宝项目,您可以访问who.

传家宝工具箱中是标准的Unix工具的集合。

亮点是:

  • 源自CalderaSun作为开源发布的原始 Unix 材料

who此发行版中随附的手册页也具有相同的“功能”,只是它更明显。

$ groff -Tascii -man who.1 |less
...

SYNOPSIS
       who [-abdHlmpqRrstTu] [utmp_file]
       who -q [-n x] [utmp_file]
       who [am i]
       who [am I]
...
...
       With the two-argument synopsis forms `who am i' and  `who  am  I',  who
       tells who you are logged in as.
...
...
Run Code Online (Sandbox Code Playgroud)


unx*_*nut 6

命令是who. 你可以给它任何参数,比如mom likesLinux 不会抱怨。其目的是获取登录系统的人员列表。