Linux ps命令

语法

ps [options]

参数描述
a显示所有进程,默认只显示当前终端的进程
x显示没有控制终端的进程
u使用基于用户信息的模式

结果展示

参数描述
USER进程所属用户名
PID进程ID
%CPUCPU占用百分比
%MEM内存占用百分比
VSZ进程虚拟大小
RSS驻留内存大小
TTY控制终端ID
STATR(Runnable),D(In uninterryptible sleep),S(Sleeping),T(Traced or stopped),Z(Zombie)
Time已经消耗的CPU时间
COMMAND进程命令

进程状态

状态描述
Runnable资源准备就绪,等待CPU时间处理数据
Sleeping等待特定事件,比如交互shell
Zombies结束执行,没有收集完所有状态
Stopped停止,收到stop信号,比如Ctrl+Z

参数

简单进程选择

参数描述
aLift the BSD-style “only yourself” restriction
-aSelect all processes except both session leaders and processes not associated with a terminal.
-dSelect all processes except session leaders.
-eSelect all processes.
-NSelect all processes except those that fulfill the specified conditions (negates the selection)
T打印但前终端的进程
rRestrict the selection to only running processes.
xLift the BSD-style “must have a tty” restriction

使用列表选择进程

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

输出格式选择

参数描述
-cShow different scheduler information for the -l option
-fDo full-format listing.
jBSD job control format.
-jJobs format.
lDisplay BSD long format.
-lLong format. The -y option is often useful with this.
-MAdd a column of security data. Identical to Z (for SELinux).
O formatis preloaded o (overloaded).
-O formatLike -o, but preloaded with some default columns.
o formatSpecify user-defined format.
-o formatUser-defined format.
sDisplay signal format.
uDisplay user-oriented format.
vDisplay virtual memory format.
XRegister format…
-yDo not show flags; show rss in place of addr.
ZAdd a column of security data. Identical to -M (for SELinux).

输出编辑器

参数描述
cShow the true command name.
eshow the environment after the command.
fASCII art process hierarchy (forest)
hNo header.
-HShow process hierarchy (forest).
kspec Specify sorting order.
-n namelistSet namelist file.
nNumeric output for WCHAN and USER
N namelistSpecify namelist file.
O orderSorting order (overloaded).
SSum up some information
-wWide output. Use this option twice for unlimited width.

线程展示

参数描述
HShow threads as if they were processes.
-LShow threads, possibly with LWP and NLWP columns.
mShow threads after processes.
-mShow threads after processes.
-TShow 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=

jps

jps 是 java ps 只显示java的进程

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值