This version of ps accepts several kinds of options:
1 UNIX options, which may be grouped and must be preceded by a
dash.
2 BSD options, which may be grouped and must not be used with a
dash.
3 GNU long options, which are preceded by two dashes.
因此,ef使用 BSDe和f选项,并-ef使用 Unix-e和-f选项。这些是不同的(部分SIMPLE PROCESS SELECTION和OUTPUT FORMAT CONTROL分别OUTPUT MODIFIERS):
-e Select all processes. Identical to -A.
-f Do full-format listing. This option can be combined with many
other UNIX-style options to add additional columns. It also
causes the command arguments to be printed. When used with
-L, the NLWP (number of threads) and LWP (thread ID) columns
will be added. See the c option, the format keyword args, and
the format keyword comm.
e Show the environment after the command.
f ASCII art process hierarchy (forest).
显然,您不是使用ef选项选择所有进程,而是使用默认的进程列表,以及一些额外的格式:
By default, ps selects all processes with the same effective user ID
(euid=EUID) as the current user and associated with the same terminal
as the invoker. It displays the process ID (pid=PID), the terminal
associated with the process (tname=TTY), the cumulated CPU time in
[DD-]hh:mm:ss format (time=TIME), and the executable name (ucmd=CMD).
Output is unsorted by default.
The use of BSD-style options will add process state (stat=STAT) to
the default display and show the command args (args=COMMAND) instead
of the executable name. You can override this with the PS_FORMAT
environment variable. The use of BSD-style options will also change
the process selection to include processes on other terminals (TTYs)
that are owned by you; alternately, this may be described as setting
the selection to be the set of all processes filtered to exclude
processes owned by other users or not on a terminal.
EXAMPLES
To see every process on the system using standard syntax:
ps -e
ps -ef
ps -eF
ps -ely
To see every process on the system using BSD syntax:
ps ax
ps axu
To print a process tree:
ps -ejH
ps axjf
This version of ps accepts several kinds of options:
1 UNIX options, which may be grouped and must be preceded by a dash.
2 BSD options, which may be grouped and must not be used with a dash.
3 GNU long options, which are preceded by two dashes.
所以第一种方法 ( ps ef) 是 BSD 风格,手册页继续
使用 BSD 样式选项会将进程状态 (stat=STAT) 添加到默认显示并显示命令 args (args=COMMAND) 而不是可执行文件名称。您可以使用 PS_FORMAT 环境变量覆盖它。使用 BSD 样式的选项也会更改进程选择,以包括您拥有的其他终端 (TTY) 上的进程;或者,这可以描述为将选择设置为所有进程的集合,这些进程被过滤以排除其他用户拥有或不在终端上的进程。These effects are not considered when options are described as being "identical" below, so -M will be considered identical to Z and so on.
man ps
说:因此,
ef
使用 BSDe
和f
选项,并-ef
使用 Unix-e
和-f
选项。这些是不同的(部分SIMPLE PROCESS SELECTION
和OUTPUT FORMAT CONTROL
分别OUTPUT MODIFIERS
):显然,您不是使用
ef
选项选择所有进程,而是使用默认的进程列表,以及一些额外的格式:你应该使用哪个?你想对输出做什么?
另外,请参阅该
EXAMPLES
部分(它确实列出了-ef
相当突出的内容,并且根本不使用 BSDe
选项):看
man ps
(你系统上的那个,网上可以有不同的解释)。所以第一种方法 (
ps ef
) 是 BSD 风格,手册页继续所以两者都是有效的命令,但它们没有显示相同的信息。