1. 程式人生 > >ps命令詳解-ps aux與ps -ef區別

ps命令詳解-ps aux與ps -ef區別

D 不可中斷 uninterruptible sleep (usually IO) 
R 執行 runnable (on run queue) 
S 中斷 sleeping 
T 停止 traced or stopped 
Z 僵死 a defunct (”zombie”) process 


這裡重點討論的是ps aux和ps –aux的區別,及ps aux和ps –ef的區別。 

1. ps aux和ps –aux
man ps 之後得到的結果: 
ps displays information about a selection of the active processes. If you want a repetitive update of the selection and the displayed information, use top(1) instead. 


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. 
意思是: 
請注意"ps -aux"不同於"ps aux"。POSIX和UNIX的標準要求"ps -aux"列印使用者名稱為"x"的使用者的所有程序,以及列印所有將由-a選項選擇的過程。如果使用者名稱為"x"不存在,ps的將會解釋為"ps aux",而且會列印一個警告。這種行為是為了幫助轉換舊指令碼和習慣。它是脆弱的,即將更改,因此不應依賴。 

如果你執行ps -aux >/dev/null,那麼你就會得到下面這行警告資訊 
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html 

綜上: 使用時兩者之間直接選擇ps aux

2. ps aux 和ps -ef
兩者的輸出結果差別不大,但展示風格不同。aux是BSD風格,-ef是System V風格。這是次要的區別,一個影響使用的區別是aux會截斷command列,而-ef不會。當結合grep時這種區別會影響到結果。