你经常在命令行中传递选项,以使函数的行为有所不同。它们都有各自的含义,例如:
- `-v` 表示 "详细模式" - `-l` 表示 "列表模式"
`ps` 命令用于列出所有正在运行的进程,但如果你传递 `-aux` 选项,它将显示所有用户的进程,
- `-v` 表示 "详细模式" - `-l` 表示 "列表模式"
`ps` 命令用于列出所有正在运行的进程,但如果你传递 `-aux` 选项,它将显示所有用户的进程,
man ps
,ps
命令的手册页(仅摘录): a Lift the BSD-style "only yourself" restriction, which is imposed
upon the set of all processes when some BSD-style (without "-")
options are used or when the ps personality setting is BSD-like.
The set of processes selected in this manner is in addition to
the set of processes selected by other means. An alternate
description is that this option causes ps to list all processes
with a terminal (tty), or to list all processes when used
together with the x option.
x Lift the BSD-style "must have a tty" restriction, which is
imposed upon the set of all processes when some BSD-style
(without "-") options are used or when the ps personality
setting is BSD-like. The set of processes selected in this
manner is in addition to the set of processes selected by other
means. An alternate description is that this option causes ps
to list all processes owned by you (same EUID as ps), or to list
all processes when used together with the a option.
u Display user-oriented format.
a
参数允许ps
显示所有用户的进程,而不仅限于当前用户。
x
使ps
在列表中包括未连接到任何终端的进程。因此,ax
一起使ps
无限制地列出所有进程。
u
只是改变输出格式和可见列。
ps
有点特殊,因为它支持BSD风格(a
)和GNU风格(-a
)的两个参数。因此,尽管可能会实现相同的功能以便更容易迁移,但ps aux
并不完全等同于ps -aux
。手册的相关段落如下所示: Note that "ps -aux" is distinct from "ps aux". The POSIX and UNIX
standards require that "ps -aux" print all processes owned by a user
named "x", as well as printing all processes that would be selected by
the -a option. If the user named "x" does not exist, this ps may
interpret the command as "ps aux" instead and print a warning. This
behavior is intended to aid in transitioning old scripts and habits.
It is fragile, subject to change, and thus should not be relied upon.
man ps
命令,我相信a
选项表示所有进程,x
选项表示当前用户拥有的所有进程,而带有a
选项和u
选项则表示用户列表中所有用户的所有进程。 - George Udosen