Linux ps命令

来源:互联网 发布:java object notify 编辑:程序博客网 时间:2024/06/15 18:35

语法

ps [options]

参数

简单进程选择

参数 描述 a Lift the BSD-style “only yourself” restriction -a Select all processes except both session leaders and processes not associated with a terminal. -d Select all processes except session leaders. -e Select all processes. -N Select all processes except those that fulfill the specified conditions (negates the selection) T 打印但前终端的进程 r Restrict the selection to only running processes. x Lift the BSD-style “must have a tty” restriction

使用列表选择进程

参数 描述 -123 Identical to –pid 123. -C cmdlist 通过命令名称选择 -G grplist 通过组id选择 -g grplist Select by session OR by effective group name. -p pidlist 通过进程id选择 -q pidlist Select by PID (quick mode). -s sesslist 通过会话选择 -t ttylist Select by tty. -u userlist 通过使用者的id或name选择

输出格式选择

参数 描述 -c Show different scheduler information for the -l option -f Do full-format listing. j BSD job control format. -j Jobs format. l Display BSD long format. -l Long format. The -y option is often useful with this. -M Add a column of security data. Identical to Z (for SELinux). O format is preloaded o (overloaded). -O format Like -o, but preloaded with some default columns. o format Specify user-defined format. -o format User-defined format. s Display signal format. u Display user-oriented format. v Display virtual memory format. X Register format.. -y Do not show flags; show rss in place of addr. Z Add a column of security data. Identical to -M (for SELinux).

输出编辑器

参数 描述 c Show the true command name. e show the environment after the command. f ASCII art process hierarchy (forest) h No header. -H Show process hierarchy (forest). k spec Specify sorting order. -n namelist Set namelist file. n Numeric output for WCHAN and USER N namelist Specify namelist file. O order Sorting order (overloaded). S Sum up some information -w Wide output. Use this option twice for unlimited width.

线程展示

参数 描述 H Show threads as if they were processes. -L Show threads, possibly with LWP and NLWP columns. m Show threads after processes. -m Show threads after processes. -T Show threads, possibly with SPID column.

实例

参数 描述 ps -e,-ef,-eF,-ely 使用标准语法查看系统上的每一个进程 ps ax,aux 使用BSD语法查看所有进程 ps -ejH,axjf 打印进程树 ps -eLf,axms 获得线程信息 ps -eo euser,ruser,suser,fuser,f,comm,labe or axZ, -eM 获得安全信息 ps -U root -u root u 查看根用户进程
       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 -Ao pid,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=
原创粉丝点击