Чтобы к использованию PS ef или PS-ef?

Я вижу, что существует различие в выводе между ps ef и ps -ef. Каково то различие, обе команды корректны или который предпочтен?

11
задан 3 August 2017 в 01:06

2 ответа

Посмотрите man ps (тот в Вашей системе, онлайн может иметь различные объяснения).

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.

Так 1-й метод (ps ef) стиль BSD, и страница руководства продолжает

Использование BSD-параметров-стиля добавит состояние процесса (stat=STAT) к дисплею по умолчанию и покажет команду args (args=COMMAND) вместо исполняемого имени. Можно переопределить это с переменной среды PS_FORMAT. Использование BSD-параметров-стиля также изменит выбор процесса для включения процессов в другие терминалы (TTYs), которые принадлежат Вам; поочередно, это может быть описано как установка выбора, чтобы быть набором всех процессов, фильтрованных для исключения процессов, принадлежавших другим пользователям или не на терминале. Эти эффекты не рассматривают, когда опции описаны как являющийся "идентичным" ниже, таким образом-M будут считать идентичным Z и так далее.

Таким образом, оба - допустимые команды, но они не показывают ту же информацию.

17
ответ дан 23 November 2019 в 03:51

man ps говорит:

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 использует BSD e и 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 раздел (который действительно перечисляет -ef скорее заметно, и не использует BSD e опция вообще):

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
18
ответ дан 23 November 2019 в 03:51

Другие вопросы по тегам:

Похожие вопросы: