Which to use of ps ef or ps -ef?
man ps
says:
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.
So, ef
uses the BSD e
and f
options, and -ef
uses the Unix -e
and -f
options. These are different (sections SIMPLE PROCESS SELECTION
, OUTPUT FORMAT CONTROL
and OUTPUT MODIFIERS
respectively):
-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).
Clearly, you're not selecting all processes using the ef
options, but are using the default listing of processes, plus some additional formatting:
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.
Which should you use? What do you want to do with the output?
Also, see the EXAMPLES
section (which does list -ef
rather prominently, and doesn't use the BSD e
option at all):
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
See man ps
(the one on your system, on-line can have different explanations).
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.
So the 1st method (ps ef
) is BSD style and the manual page goes on with
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. These effects are not considered when options are described as being "identical" below, so -M will be considered identical to Z and so on.
So both are valid commands but they are not showing the same information.