ps aux
sembra elencare convenientemente tutti i processi e il loro stato e utilizzo delle risorse (Linux/BSD/MacOS), tuttavia non riesco a comprendere il significato del parametro aux
usando man ps
.
Cosa significa aux
?
a = mostra i processi per tutti gli utenti
u = visualizza l'utente/proprietario del processo
x = mostra anche i processi non collegati a un terminale
A proposito, man ps
è una buona risorsa.
Storicamente, BSD e AT&T hanno sviluppato versioni incompatibili di ps
. Le opzioni senza trattino iniziale (come da domanda) sono in stile BSD, mentre quelle con trattino iniziale sono in stile Unix AT&T. Inoltre, Linux ha sviluppato una versione che supporta entrambi gli stili e quindi aggiunge un terzo stile con opzioni che iniziano con doppi trattini.
Tutte (o quasi) le distribuzioni Linux non incorporate usano una variante della suite procps . Le opzioni precedenti sono definite nella procps ps
man page .
Nei commenti, dici che stai usando Apple MacOS (OSX, presumo). La pagina man OSX per ps
è qui e mostra supporto solo per stile AT&T.
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.
u Display user-oriented format.
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.
$ ps aux | head -10
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 51120 2796 ? Ss Dec22 0:09 /usr/lib/systemd/systemd --system --deserialize 22
root 2 0.0 0.0 0 0 ? S Dec22 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S Dec22 0:04 [ksoftirqd/0]
root 5 0.0 0.0 0 0 ? S< Dec22 0:00 [kworker/0:0H]
root 7 0.0 0.0 0 0 ? S Dec22 0:15 [migration/0]
root 8 0.0 0.0 0 0 ? S Dec22 0:00 [rcu_bh]
root 9 0.0 0.0 0 0 ? S Dec22 2:47 [rcu_sched]
...
saml 3015 0.0 0.0 117756 596 pts/2 Ss Dec22 0:00 bash
saml 3093 0.9 4.1 1539436 330796 ? Sl Dec22 70:16 /usr/lib64/Thunderbird/thunderbird
saml 3873 0.0 0.1 1482432 8628 ? Sl Dec22 0:02 gvim -f
root 5675 0.0 0.0 124096 412 ? Ss Dec22 0:02 /usr/sbin/crond -n
root 5777 0.0 0.0 51132 1068 ? Ss Dec22 0:08 /usr/sbin/wpa_supplicant -u -f /var/log/wpa_supplica
saml 5987 0.7 1.5 1237740 119876 ? Sl Dec26 14:05 /opt/google/chrome/chrome --type=renderer --lang=en-
root 6115 0.0 0.0 0 0 ? S Dec27 0:06 [kworker/0:2]
...
Con le opzioni sopra riportate otterrai l'output relativo ai tuoi processi come sopra.
Gli switch aux
ti mostreranno:
La chiave per comprendere manpage non è cercare "aux" (che ho provato prima), ma concentrarsi sulla sezione che descrive i tipi di parametro ps
:
Questa versione di ps accetta diversi tipi di opzioni:
- Opzioni UNIX, che possono essere raggruppate e devono essere precedute da un trattino.
- Opzioni BSD, che possono essere raggruppate e non devono essere utilizzate con un trattino.
- Opzioni GNU lunghe, precedute da due trattini.
Da questo, sappiamo che aux
è un insieme di opzioni (raggruppate) di BSD, a
, u
e x
, che le rende leggermente più facili da guardare su.
a
e x
controllano quali processi sono selezionati e utilizzati insieme sono esplicitamente descritti per selezionare tutti i processi.
u
genera un output usando il formato "orientato all'utente", che fornisce più colonne, incluso l'id utente e l'utilizzo della CPU/memoria.
Poiché u
controlla da solo il formato di output, puoi ottenere output in stile "ps aux" solo per processi specifici con ps u $pid1 $pid2 ...
.