********* simple selection ********* ********* selection by list ********* -A all processes -C by command name -N negate selection -G by real group ID (supports names) -a all w/ tty except session leaders -U by real user ID (supports names) -d all except session leaders -g by session OR by effective group name -e all processes -p by process ID -q by process ID (unsorted & quick) T all processes on this terminal -s processes in the sessions given a all w/ tty, including other users -t by tty g OBSOLETE -- DO NOT USE -u by effective user ID (supports names) r only running processes U processes for specified users x processes w/o controlling ttys t by tty *********** output format ********** *********** long options *********** -o,o user-defined -f full --Group --User --pid --cols --ppid -j,j job control s signal --group --user --sid --rows --info -O,O preloaded -o v virtual memory --cumulative --format --deselect -l,l long u user-oriented --sort --tty --forest --version -F extra full X registers --heading --no-heading --context --quick-pid ********* misc options ********* -V,V show version L list format codes f ASCII art forest -m,m,-L,-T,H threads S children in sum -y change -l format -M,Z security data c true command name -c scheduling class -w,w wide output n numeric WCHAN,UID -H process hierarchy
********* simple selection ********* ********* selection by list ********* -A all processes -C by command name -N negate selection -G by real group ID (supports names) -a all w/ tty except session leaders -U by real user ID (supports names) -d all except session leaders -g by session OR by effective group name -e all processes -p by process ID -q by process ID (unsorted & quick) T all processes on this terminal -s processes in the sessions given a all w/ tty, including other users -t by tty g OBSOLETE -- DO NOT USE -u by effective user ID (supports names) r only running processes U processes for specified users x processes w/o controlling ttys t by tty *********** output format ********** *********** long options *********** -o,o user-defined -f full --Group --User --pid --cols --ppid -j,j job control s signal --group --user --sid --rows --info -O,O preloaded -o v virtual memory --cumulative --format --deselect -l,l long u user-oriented --sort --tty --forest --version -F extra full X registers --heading --no-heading --context --quick-pid ********* misc options ********* -V,V show version L list format codes f ASCII art forest -m,m,-L,-T,H threads S children in sum -y change -l format -M,Z security data c true command name -c scheduling class -w,w wide output n numeric WCHAN,UID -H process hierarchy
PS(1) Linux User’s Manual PS(1)
名前
ps - 現在実行されているプロセスのスナップショットを表示する
書式
ps [options]
説明
ps はアクティブなプロセスのうち選択されたものの情報を表示する。プロセスの選択
や表示される情報を繰り返し更新したい場合は、代わりに top(1) を使うこと。
このバージョンの ps が受け付けるオプションにはいくつかの種類がある。
1 UNIX オプション。まとめることが可能で、前にはダッシュを置かなければならな
い。
2 BSD オプション。まとめることが可能で、ダッシュを使ってはならない。
3 GNU ロングオプション。前に二つのダッシュを置く。
別々の種類のオプションは自由に混在させてよいが、衝突が起こるかもしれない。機能
的には全く等しい、同義のオプションがいくつかある。これは多くの標準と ps 実装に
対して、この ps が互換性を持っているためである。
"ps -aux" は "ps aux" とは異なることに注意すること。 POSIX と UNIX 標準では
、"ps -aux" は "x" という名前のユーザーが所有する全てのプロセスを表示し、かつ
-a オプションで選択される全てのプロセスを表示する。 "x" という名前のユーザーが
存在しない場合、この ps は代わりに "ps aux" というコマンドとして解釈され、警告
を表示する。この動作は昔のスクリプトと慣習からの移行の助けになることを意図して
いる。これは脆くて変更される可能性があるので、これに依存すべきではない。
デフォルトでは、ps はカレントユーザーと同じ実効 (effective) ユーザー ID (EUID)
を持ち、かつ呼び出した端末と同じ端末に関連づけられている全てのプロセスを選択す
る。この場合、プロセス ID (PID)・プロセスに関連づけられている端末 (TTY)・
[dd-]hh:mm:ss という形式の累積 CPU 時間 (TIME)・実行ファイル名 (CMD) が表示さ
れる。出力はデフォルトではソートされない。
BSD 形式オプションを使うと、デフォルトの表示にプロセス状態 (STAT) が追加され、
実行ファイル名の代わりにコマンドライン引き数 (COMMAND) が表示される。これは
PS_FORMAT 環境変数で上書きできる。 BSD 形式オプションを使った場合、選択される
プロセスも変わり、ユーザが所有する他の端末 (TTY) 上のプロセスも含まれるように
なる。言い換えれば、選択されるプロセスは、全てのプロセスから他のユーザーが所有
するプロセスと端末上にないプロセスを除いたものに設定されると説明できる。以下で
オプションが「等しい ("identical")」と書かれているものについては、これらの違い
は除いて考える。したがって、-M は Z と等しく、他も同様である。
以下で記述されているものを除き、個々のプロセス選択オプションで選択されたプロセ
スは足し合わされる。デフォルトの選択は破棄され、選択されたプロセスは表示される
プロセス群に追加される。したがって、あるプロセスは、指定された選択基準のどれか
ひとつに合致すれば、表示される。
例
標準的な書式を使ってシステム上の全てのプロセスを表示する:
ps -e
ps -ef
ps -eF
ps -ely
BSD 書式を使ってシステム上の全てのプロセスを表示する:
ps ax
ps axu
プロセスツリーを表示する:
ps -ejH
ps axjf
スレッドに関する情報を取得する:
ps -eLf
ps axms
セキュリティ情報を取得する:
ps -eo euser,ruser,suser,fuser,f,comm,label
ps axZ
ps -eM
root (実 (real) ID と実効 ID) として実行されている全てのプロセスを
ユーザ形式で表示する: ps -U root -u root u
全てのプロセスをユーザー定義フォーマットで表示する:
ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm
ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm
ps -eopid,tt,user,fname,tmout,f,wchan
syslogd のプロセス ID のみを表示する:
ps -C syslogd -o pid=
PID 42 の名前のみを表示する。
ps -p 42 -o comm=
簡易プロセス選択
-A 全てのプロセスを選択する。-e と等しい。
-N 指定された条件を満たさないプロセスのみを選択する (選択の否定)
。 --deselect と等しい。
T この端末の全てのプロセスを選択する。引き数なしの t オプション
と等しい。
-a セッションリーダ (getsid(2) を参照) と端末を持たないプロセスを
除く、全てのプロセスを表示する。
a BSD 形式の ("-" のない) オプションが使用された場合、または ps
の流儀 (personality) の設定が BSD 形式の場合に、全てのプロセス
の集合に対して課される「自分自身のみ」という BSD 形式の制約を
なくす。この方式で選択されたプロセスの集合は、他の手段で選ばれ
たプロセスの集合に加えられる。このオプションの別の説明は以下の
通り: このオプションを指定すると、 ps は端末 (tty) を持つ全て
のプロセスをリストする。また x オプションと共に指定すると、全
てのプロセスをリストする。
-d セッションリーダを除く全てのプロセスを選択する。
-e 全てのプロセスを選択する。-A と等しい。
g 本当に全てのプロセスを選択する。セッションリーダも含む。このフ
ラグは旧式で、将来のリリースでは廃止されるかもしれない。この振
る舞いは通常 a フラグで暗黙に有効になり、 sunos4 の流儀で操作
するときにのみ役立つ。
r 実行中のプロセスのみに選択を限定する。
x BSD 形式の ("-" のない) オプションが使用された場合、または ps
の流儀の設定が BSD 形式の場合に、全てのプロセスの集合に対して
課される「端末を持たなければならない」という BSD 形式の制約を
なくす。この方式で選択されたプロセスの集合は、他の手段で選ばれ
たプロセスの集合に加えられる。このオプションの別の説明は以下の
通り: このオプションを指定すると、ps は呼び出したユーザーの所
有する (ps と同じ EUID の) 全てのプロセスをリストする。また a
オプションと共に指定すると、全てのプロセスをリストする。
--deselect 指定された条件を満たさないプロセスのみを選択する (選択の否定)
。 -N と等しい。
リストによるプロセス選択
これらのオプションは空白区切りまたはコンマ区切り形式の 1 つの引き数を受け付け
、複数回指定できる。例: ps -p "1 2" -p 3,4
-C cmdlist コマンド名で選択する。
実行ファイル名が cmdlist に含まれるプロセスを選択する。
-G grplist 実グループ ID または実グループ名で選択する。
実グループ名または実グループ ID が grplist リストに含まれるプ
ロセスを選択する。実グループ ID とはプロセスを作成したユーザー
のグループである。 getgid(2) を参照。
U userlist 実効ユーザー ID (EUID) または実効ユーザー名で選択する。
実効ユーザー名または実効ユーザー ID が userlist に含まれるプロ
セスを選択する。実効ユーザー ID はそのファイルアクセス許可がプ
ロセスによって使用される (geteuid(2) を参照)。 -u, --user と等
しい。
-U userlist 実ユーザー ID (RUID) または実ユーザー名で選択する。
実ユーザー名または実ユーザー ID が userlist に含まれるプロセス
を選択する。実ユーザー ID はプロセスを作成したユーザーを識別す
る。 getuid(2) を参照。
-g grplist セッションと実効グループ名の OR で選択する。
セッションによる選択は多くの標準で指定されているが、実効グルー
プ ID による選択は、いくつかのオペレーティングシステムで使用さ
れている論理的な動作である。この ps はリストが (セッションを表
す) 数値だけの場合、セッションで選択する。グループ ID 番号によ
る選択は、他のグループ名が指定されている場合にのみ動作する。
-s と --group オプションを参照すること。
p pidlist プロセス ID で選択する。-p, --pid と等しい。
-p pidlist PID で選択する。
プロセス ID 番号が pidlist にあるプロセスを選択する。 p, --pid
と等しい。
-s sesslist セッション ID で選択する。
sesslist で指定されたセッション ID のプロセスを選択する。
t ttylist 端末 (tty) で選択する。 -t, --tty とほぼ等しいが、空の ttylist
を使うことで、 ps と関連づけられている端末を表すことができる。
T オプションを使う方が、t と空の ttylist を使うより、すっきり
している。
-t ttylist 端末 (tty) で選択する。
ttylist で指定された端末と関連づけられているプロセスを選択する
。端末 (テキスト出力のための tty またはスクリーン) は、いくつ
かの形式で指定できる: /dev/ttyS1, ttyS1, S1. 単なる "-" は、ど
の端末にも属さないプロセスを選択するのに使用される。
-u userlist 実効ユーザー ID (EUID) または実効ユーザー名で選択する。
userlist にある実効ユーザー名または実効ユーザー ID のプロセス
を選択する。実効ユーザー ID は、プロセスによってファイルアクセ
ス許可が使用されるユーザーを表す (geteuid(2) を参照)。 U,
--user と等しい。
--Group grplist
実グループ ID (RGID) または実グループ名で選択する。-G と等しい
。
--User userlist
実ユーザー ID (RUID) または実ユーザー名で選択する。-U と等しい
。
--group grplist
実効グループ ID (EGID) または実効グループ名で選択する。
実効グループ名または実効グループ ID が grouplist にあるプロセ
スを選択する。実効グループ ID は、プロセスによってファイルアク
セス許可が使用されるグループを表す (geteuid(2) を参照)。 -g は
、しばしば --group の代わりとされる。
--pid pidlist プロセス ID で選択する。-p, p と等しい。
--ppid pidlist 親プロセスのプロセス ID で選択する。親プロセスの ID が pidlist
にあるプロセスを選択する。つまり、pidlist にリストされているプ
ロセスの子プロセスを選択する。
--sid sesslist セッション ID で選択する。-s と等しい。
--tty ttylist 端末で選択する。-t, t と等しい。
--user userlist
実効ユーザー ID (EUID) または実効ユーザー名で選択する。 -u, U
と等しい。
-123 --sid 123 と等しい。
123 --pid 123 と等しい。
出力フォーマットの制御
これらのオプションは、ps によって表示される情報を選択するのに使用される。出力
は流儀によって異なる可能性がある。
-F 特別に完全なフォーマット。 -F が暗黙のうちに指定する -f オプシ
ョンを参照すること。
-O format -o と似ているが、いくつかのデフォルトカラムをプリロードする。
-o pid,format,state,tname,time,command または
-o pid,format,tname,time,cmd と等しい。下記の -o を参照するこ
と。
O format プリロードされた o (上書きされる)。
BSD の O オプションは、-O (ユーザー定義の出力フォーマット。い
くつかのよく使われるフィールドは定義済) オプションのように動作
したり、あるいはソートの順序指定にも用いることができる。このオ
プションにどちらの動作をさせるかは、ヒューリスティックな手法を
用いて決定する。 (ソートあるいはフォーマットについて) 望みの動
作をさせるには、その他のオプションを指定すること。 (例えば、-O
または --sort と一緒に指定する)。
フォーマットオプションとして使用する場合は、 BSD の流儀で -O
を指定するのと等しい。
-M セキュリティデータのカラムを追加する。 Z と同じ。(SE Linux 用)
。
X レジスタフォーマット
Z セキュリティデータのカラムを追加する。 -M と同じ。(SE Linux
用)。
-c -l オプションとは異なるスケジューリング情報を表示する。
-f 完全なフォーマットでリストする。このオプションは、他の多くの
UNIX 形式オプションと組み合わせることが可能で、その他のカラム
を追加する。またコマンドライン引き数も表示される。 -L と組み合
わせて使うと、 NLWP (スレッド数), LWP (スレッド ID) カラムが追
加される。フォーマットキーワード args と comm については、 c
オプションを参照すること。
j BSD のジョブ制御フォーマット。
-j jobs フォーマット。
l BSD の長いフォーマット。
-l 長いフォーマット。 -y オプションは、このオプションと組み合わせ
ることで、しばしば役に立つ。
o format ユーザー定義フォーマットを指定する。 -o, --format と等しい。
-o format ユーザー定義フォーマット。
format は空白区切りまたはコンマ区切りリストの形式の 1 つの引き
数である。これにより各出力カラムを指定する方法を提供している。
「標準フォーマット指定子」のセクションで説明されているキーワー
ドを認識する。ヘッダは望みのものに変更できる
(ps -o pid,ruser=RealUser -o comm=Command)。全てのカラムヘッダ
が空の場合 (ps -o pid= -o comm=)、ヘッダ行は出力されない。ヘッ
ダの幅が広い場合は、カラム幅が増やされる。これは WCHAN のよう
なカラムの幅を広げるのに使われる
(ps -o pid,wchan=WIDE-WCHAN-COLUMN -o comm)。明示的な幅の制御
(ps opid,wchan:42,cmd) も提供されている。 ps -o pid=X,comm=Y
の挙動は流儀によって変わる。 "X,comm=Y" という名前の 1 つのカ
ラムが出力される場合もあるし、 "X" と "Y" という名前の 2 つの
カラムが出力される場合もある。疑わしい場合は、-o オプションを
複数使うこと。デフォルトを望みのものにしたい場合は、 PS_FORMAT
環境変数を使うこと。 DefSysV と DefBSD は、デフォルトの UNIX
または BSD カラムを選択するためのマクロである。
s シグナルフォーマット。
u ユーザー指向のフォーマット。
v 仮想メモリフォーマット。
-y フラグを表示しない。addr の代わりに rss を表示する。このオプシ
ョンは -l と一緒のときにのみ使用できる。
--format format
ユーザー定義フォーマット。 -o, o と等しい。
--context セキュリティコンテキストフォーマット (SE Linux 用)。
出力修正指定
-H プロセスを階層表示する (森)。
N namelist 名前リストファイルを指定する。 -n と等しい。上記の -n を参照す
ること。
O order ソート順の指定 (上書きされる)。
BSD の O オプションは、-O (ユーザー定義の出力フォーマット。い
くつかのよく使われるフィールドは定義済) オプションのように動作
したり、あるいはソートの順序指定にも用いることができる。このオ
プションにどちらの動作をさせるかは、ヒューリスティックな手法を
用いて決定する。 (ソートあるいはフォーマットについて) 望みの動
作をさせるには、その他のオプションを指定すること。 (例えば、-O
または --sort と一緒に指定する)。
ソートに用いる場合、廃止された BSD の O オプションの文法は
O[+|-]k1[,[+|-]k2[,...]] である。「廃止されたソートキー」にあ
る 1 文字の短いキーのシーケンスを k1, k2, ... に指定すれば、プ
ロセスリストを複数レベルでソートできる。
"+" は現在では省略可能な指定で、単にデフォルトのソート方向を繰
り返しているに過ぎない。 O ソートと O フォーマットを区別する助
けになる。 "-" はその直後のキーのソート順を逆順にする。
S 死んだ子プロセスの CPU 使用量といった情報を、親プロセスに加算
する。親プロセスが寿命の短い子プロセスを繰り返し fork して処理
を行なうようなシステムを調べるのに役に立つ。
c 本当のコマンド名を表示する。これは argv の値ではなく、実行ファ
イル名から導き出される。よって、コマンド引き数とそれを修正した
もの (setproctitle(3) を参照) は表示されない。実際上、このオプ
ションは args フォーマットキーワードを comm フォーマットキーワ
ードに置き換える。これは -f フォーマットオプションを、様々な
BSD 形式のフォーマットオプション (通常は全てのオプションがコマ
ンド引き数を表示する) とともに使う場合に役に立つ。 -f オプショ
ン、およびフォーマットキーワード args とcomm を参照すること。
e コマンドの後に環境を表示する。
f ASCII アートでプロセス階層を表示する (森)。
h へッダ行を表示しない (また BSD 流儀の場合はスクリーンごとに 1
つのへッダ行)
h オプションには問題がある。標準的な BSD の ps では、このオプ
ションは出力の各ページにヘッダを出力することになるが、古い
Linux の ps ではヘッダを全く出力しないことになる。この ps では
Linux の利用法に倣い、ヘッダを出力しない。ただし別途 BSD の流
儀が選択されていれば、出力の各ページにヘッダを出力するようにな
る。長いオプションである --headers や --no-headers を使えば、
現在の流儀に関係なく、各ページにヘッダを出力するか、全くヘッダ
を出力しないかを選択することができる。
k spec ソート順を指定する。ソート文法は [+|-]key[,[+|-]key[,...]] で
ある。複数文字のキーは「標準フォーマット指定子」のセクションか
ら選ぶこと。デフォルトのソートの方向は数値順・辞書順ともに昇順
なので、"+" は省略してよい。 --sort と等しい。例:
ps jaxkuid,-ppid,+pid
ps axk comm o comm,args
ps kstart_time -ef
-n namelist 名前リストファイルを指定する。 N と等しい。
WCHAN の表示を正しく行うには、 名前リストファイルが必要である
。正しい出力のためには、名前リストファイルは現在の Linux カー
ネルに正確に一致するものでなければならない。このオプションを指
定しない場合、名前リストのデフォルトの検索パスは以下の通り:
$PS_SYSMAP
$PS_SYSTEM_MAP
/proc/*/wchan
/boot/System.map-`uname -r`
/boot/System.map
/lib/modules/`uname -r`/System.map
/usr/src/linux/System.map
/System.map
n WCHAN と USER を数値で出力する (UID と GID の全てのタイプを含
む)。
-w 出力幅を広げる。このオプションを 2 つ指定すると、幅の制限がな
くなる。
w 出力幅を広げる。このオプションを 2 つ指定すると、幅の制限がな
くなる。
--cols n スクリーンの幅を指定する。
--columns n スクリーンの幅を指定する
--cumulative 死んだ子プロセスも (親プロセスへの加算として) 含める。
--forest ASCII アートでプロセス階層を表示する。
--headers ヘッダ行を繰り返す。出力の 1 ページ毎に 1 行。
--no-headers ヘッダ行を一切表示しない。
--lines n スクリーンの行数を設定する。
--rows n スクリーンの行数を設定する。
--sort spec ソート順を指定する。ソートの文法は [+|-]key[,[+|-]key[,...]]
である。複数文字のキーは「標準フォーマット指定子」セクションか
ら選ぶこと。デフォルトのソートの方向は数値順・辞書順ともに昇順
なので、"+" は任意である。 k と等しい。例:
ps jax --sort=uid,-ppid,+pid
--width n スクリーンの幅を指定する
スレッド表示
H スレッドをプロセスのように表示する。
-L 可能ならば LWP と NLWP カラムをつけてスレッドを表示する。
-T 可能ならば SPID カラムをつけてスレッドを表示する。
m プロセスの後にスレッドを表示する。
-m プロセスの後にスレッドを表示する。
その他の情報
L 全てのフォーマット指定子をリストする。
-V procps のバージョンを表示する。
V procps のバージョンを表示する。
--help ヘルプメッセージを表示する。
--info デバッグ情報を表示する。
--version procps のバージョンを表示する。
注意
この ps は /proc にある仮想ファイルを読み込んで動作する。この ps は kmem に
suid する必要はなく、動作にいかなる特権も必要としない。この ps に特別な許可属
性を与えないようにすること。
この ps が WCHAN の表示を正しく行うには、名前リストファイルにアクセスする必要
がある。 2.6 より前のカーネルでは、System.map ファイルがインストールされていな
ければならない。
現在のところ CPU 使用率は、プロセスの生存期間中に実行に利用した時間のパーセン
テージで表される。これは理想的ではなく、ps が準拠すべき標準に準拠していない。
CPU 使用率は足し合わせても正確に 100% になることは少ない。
SIZE フィールドと RSS フィールドには、プロセスの一部 (page tables, kernel
stack, struct thread_info, struct task_struct) が含まれない。これらは最低
20 Ki バイト以上あり、必ずメモリに常駐している。 SIZE はプロセスの仮想サイズ
(code+data+stack) である。
PS(1) Linux User’s Manual PS(1)
NAME
ps - report a snapshot of the current processes.
SYNOPSIS
ps [options]
DESCRIPTION
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.
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.
Options of different types may be freely mixed, but conflicts can
appear. There are some synonymous options, which are functionally
identical, due to the many standards and ps implementations that this
ps is compatible with.
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.
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. These effects are not considered when
options are described as being "identical" below, so -M will be
considered identical to Z and so on.
Except as described below, process selection options are additive. The
default selection is discarded, and then the selected processes are
added to the set of processes to be displayed. A process will thus be
shown if it meets any of the given selection criteria.
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
To get info about threads:
ps -eLf
ps axms
To get security info:
ps -eo euser,ruser,suser,fuser,f,comm,label
ps axZ
ps -eM
To see every process running as root (real & effective ID) in user
format:
ps -U root -u root u
To see every process with a user-defined format:
ps -eo pid,tid,class,rtprio,ni,pri,psr,pcpu,stat,wchan:14,comm
ps axo stat,euid,ruid,tty,tpgid,sess,pgrp,ppid,pid,pcpu,comm
ps -eopid,tt,user,fname,tmout,f,wchan
Print only the process IDs of syslogd:
ps -C syslogd -o pid=
Print only the name of PID 42:
ps -q 42 -o comm=
SIMPLE PROCESS SELECTION
-A Select all processes. Identical to -e.
-N Select all processes except those that fulfill the
specified conditions. (negates the selection) Identical
to --deselect.
T Select all processes associated with this terminal.
Identical to the t option without any argument.
-a Select all processes except both session leaders (see
getsid(2)) and processes not associated with a
terminal.
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.
-d Select all processes except session leaders.
-e Select all processes. Identical to -A.
g Really all, even session leaders. This flag is obsolete
and may be discontinued in a future release. It is
normally implied by the a flag, and is only useful when
operating in the sunos4 personality.
r Restrict the selection to only running processes.
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.
--deselect Select all processes except those that fulfill the
specified conditions. (negates the selection) Identical
to -N.
PROCESS SELECTION BY LIST
These options accept a single argument in the form of a blank-separated
or comma-separated list. They can be used multiple times.
For example: ps -p "1 2" -p 3,4
-C cmdlist Select by command name.
This selects the processes whose executable name is
given in cmdlist.
-G grplist Select by real group ID (RGID) or name.
This selects the processes whose real group name or ID
is in the grplist list. The real group ID identifies
the group of the user who created the process, see
getgid(2).
U userlist Select by effective user ID (EUID) or name.
This selects the processes whose effective user name or
ID is in userlist. The effective user ID describes the
user whose file access permissions are used by the
process (see geteuid(2)). Identical to -u and --user.
-U userlist select by real user ID (RUID) or name.
It selects the processes whose real user name or ID is
in the userlist list. The real user ID identifies the
user who created the process, see getuid(2).
-g grplist Select by session OR by effective group name.
Selection by session is specified by many standards,
but selection by effective group is the logical
behavior that several other operating systems use. This
ps will select by session when the list is completely
numeric (as sessions are). Group ID numbers will work
only when some group names are also specified. See the
-s and --group options.
p pidlist Select by process ID. Identical to -p and --pid.
-p pidlist Select by PID.
This selects the processes whose process ID numbers
appear in pidlist. Identical to p and --pid.
q pidlist Quick select by process ID. Identical to -q
and --quick-pid.
-q pidlist Quick select by PID.
This selects the processes whose process ID numbers
appear in pidlist. With this option ps reads the
necessary info only for the pids listed in the pidlist
and doesn’t apply additional filtering rules. The order
of pids is unsorted and preserved. No additional
selection options, sorting and forest type listings are
allowed in this mode. Identical to q and --quick-pid.
-s sesslist Select by session ID.
This selects the processes with a session ID specified
in sesslist.
t ttylist Select by tty. Nearly identical to -t and --tty, but
can also be used with an empty ttylist to indicate the
terminal associated with ps. Using the T option is
considered cleaner than using T with an empty ttylist.
-t ttylist Select by tty.
This selects the processes associated with the
terminals given in ttylist. Terminals (ttys, or screens
for text output) can be specified in several forms:
/dev/ttyS1, ttyS1, S1. A plain "-" may be used to
select processes not attached to any terminal.
-u userlist Select by effective user ID (EUID) or name.
This selects the processes whose effective user name or
ID is in userlist. The effective user ID describes the
user whose file access permissions are used by the
process (see geteuid(2)). Identical to U and --user.
--Group grplist Select by real group ID (RGID) or name. Identical to
-G.
--User userlist Select by real user ID (RUID) or name. Identical to -U.
--group grplist Select by effective group ID (EGID) or name.
This selects the processes whose effective group name
or ID is in grouplist. The effective group ID describes
the group whose file access permissions are used by the
process (see geteuid(2)). The -g option is often an
alternative to --group.
--pid pidlist Select by process ID. Identical to -p and p.
--ppid pidlist Select by parent process ID. This selects the processes
with a parent process ID in pidlist. That is, it
selects processes that are children of those listed in
pidlist.
--quick-pid pidlist
Quick select by process ID. Identical to -q and q.
--sid sesslist Select by session ID. Identical to -s.
--tty ttylist Select by terminal. Identical to -t and t.
--user userlist Select by effective user ID (EUID) or name. Identical
to -u and U.
-123 Identical to --sid 123.
123 Identical to --pid 123.
OUTPUT FORMAT CONTROL
These options are used to choose the information displayed by ps. The
output may differ by personality.
-F extra full format. See the -f option, which -F implies.
-O format is like -o, but preloaded with some default columns.
Identical to -o pid,format,state,tname,time,command or
-o pid,format,tname,time,cmd, see -o below.
O format is preloaded o (overloaded).
The BSD O option can act like -O (user-defined output
format with some common fields predefined) or can be
used to specify sort order. Heuristics are used to
determine the behavior of this option. To ensure that
the desired behavior is obtained (sorting or
formatting), specify the option in some other way (e.g.
with -O or --sort). When used as a formatting option,
it is identical to -O, with the BSD personality.
-M Add a column of security data. Identical to Z.
(for SE Linux)
X Register format.
Z Add a column of security data. Identical to -M.
(for SE Linux)
-c Show different scheduler information for the -l option.
-f does 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.
j BSD job control format.
-j jobs format
l display BSD long format.
-l long format. The -y option is often useful with this.
o format specify user-defined format. Identical to -o and
--format.
-o format user-defined format.
format is a single argument in the form of a
blank-separated or comma-separated list, which offers a
way to specify individual output columns. The
recognized keywords are described in the STANDARD
FORMAT SPECIFIERS section below. Headers may be renamed
(ps -o pid,ruser=RealUser -o comm=Command) as desired.
If all column headers are empty (ps -o pid= -o comm=)
then the header line will not be output. Column width
will increase as needed for wide headers; this may be
used to widen up columns such as WCHAN
(ps -o pid,wchan=WIDE-WCHAN-COLUMN -o comm). Explicit
width control (ps opid,wchan:42,cmd) is offered too.
The behavior of ps -o pid=X,comm=Y varies with
personality; output may be one column named "X,comm=Y"
or two columns named "X" and "Y". Use multiple -o
options when in doubt. Use the PS_FORMAT environment
variable to specify a default as desired; DefSysV and
DefBSD are macros that may be used to choose the
default UNIX or BSD columns.
s display signal format
u display user-oriented format
v display virtual memory format
-y Do not show flags; show rss in place of addr. This
option can only be used with -l.
-Z display security context format (SELinux, etc.)
--format format user-defined format. Identical to -o and o.
--context Display security context format. (for SE Linux)
OUTPUT MODIFIERS
-H show process hierarchy (forest)
N namelist Specify namelist file. Identical to -n, see -n above.
O order Sorting order. (overloaded)
The BSD O option can act like -O (user-defined output
format with some common fields predefined) or can be
used to specify sort order. Heuristics are used to
determine the behavior of this option. To ensure that
the desired behavior is obtained (sorting or
formatting), specify the option in some other way (e.g.
with -O or --sort).
For sorting, obsolete BSD O option syntax is
O[+|-]k1[,[+|-]k2[,...]]. It orders the processes
listing according to the multilevel sort specified by
the sequence of one-letter short keys k1, k2, ...
described in the OBSOLETE SORT KEYS section below.
The "+" is currently optional, merely re-iterating the
default direction on a key, but may help to distinguish
an O sort from an O format. The "-" reverses direction
only on the key it precedes.
S Sum up some information, such as CPU usage, from dead
child processes into their parent. This is useful for
examining a system where a parent process repeatedly
forks off short-lived children to do work.
c Show the true command name. This is derived from the
name of the executable file, rather than from the argv
value. Command arguments and any modifications to them
(see setproctitle(3)) are thus not shown. This option
effectively turns the args format keyword into the comm
format keyword; it is useful with the -f format option
and with the various BSD-style format options, which
all normally display the command arguments. See the -f
option, the format keyword args, and the format keyword
comm.
e Show the environment after the command.
f ASCII-art process hierarchy (forest)
h No header. (or, one header per screen in the BSD
personality)
The h option is problematic. Standard BSD ps uses this
option to print a header on each page of output, but
older Linux ps uses this option to totally disable the
header. This version of ps follows the Linux usage of
not printing the header unless the BSD personality has
been selected, in which case it prints a header on each
page of output. Regardless of the current personality,
you can use the long options --headers and --no-headers
to enable printing headers each page or disable headers
entirely, respectively.
k spec specify sorting order. Sorting syntax is
[+|-]key[,[+|-]key[,...]] Choose a multi-letter key
from the STANDARD FORMAT SPECIFIERS section. The "+" is
optional since default direction is increasing
numerical or lexicographic order. Identical to --sort.
Examples:
ps jaxkuid,-ppid,+pid
ps axk comm o comm,args
ps kstart_time -ef
-n namelist set namelist file. Identical to N.
The namelist file is needed for a proper WCHAN display,
and must match the current Linux kernel exactly for
correct output. Without this option, the default search
path for the namelist is:
$PS_SYSMAP
$PS_SYSTEM_MAP
/proc/*/wchan
/boot/System.map-`uname -r`
/boot/System.map
/lib/modules/`uname -r`/System.map
/usr/src/linux/System.map
/System.map
n Numeric output for WCHAN and USER. (including all types
of UID and GID)
-w Wide output. Use this option twice for unlimited width.
w Wide output. Use this option twice for unlimited width.
--cols n set screen width
--columns n set screen width
--cumulative include some dead child process data (as a sum with the
parent)
--forest ASCII art process tree
--headers repeat header lines, one per page of output
--no-headers print no header line at all
--lines n set screen height
--rows n set screen height
--sort spec specify sorting order. Sorting syntax is
[+|-]key[,[+|-]key[,...]] Choose a multi-letter key
from the STANDARD FORMAT SPECIFIERS section. The "+" is
optional since default direction is increasing
numerical or lexicographic order. Identical to k. For
example: ps jax --sort=uid,-ppid,+pid
--width n set screen width
THREAD DISPLAY
H Show threads as if they were processes
-L Show threads, possibly with LWP and NLWP columns
-T Show threads, possibly with SPID column
m Show threads after processes
-m Show threads after processes
OTHER INFORMATION
L List all format specifiers.
-V Print the procps version.
V Print the procps version.
--help Print a help message.
--info Print debugging info.
--version Print the procps version.
NOTES
This ps works by reading the virtual files in /proc. This ps does not
need to be setuid kmem or have any privileges to run. Do not give this
ps any special permissions.
This ps needs access to namelist data for proper WCHAN display. For
kernels prior to 2.6, the System.map file must be installed.
CPU usage is currently expressed as the percentage of time spent
running during the entire lifetime of a process. This is not ideal,
and it does not conform to the standards that ps otherwise conforms to.
CPU usage is unlikely to add up to exactly 100%.
The SIZE and RSS fields don’t count some parts of a process including
the page tables, kernel stack, struct thread_info, and struct
task_struct. This is usually at least 20 KiB of memory that is always
resident. SIZE is the virtual size of the process (code+data+stack).
Processes marked
Copyright(C) linux-cmd.com All Rights Reserved. Author Takayuki Yukawa