ps --help a #查看命令帮助
-A | -e #显示系统内所有进程
r #可运行的进程(就绪状态)[-]g[gid]#指定用户组下的进程,默认当前用户组[-]u[uid]#指定用户下的进程,默认当前用户[-]t[tty]#指定终端下的进程
a #系统内所有依赖于终端的进程[-]p<pid>#指定进程
输出结果说明
TTY字段
表示进程所依赖的终端,如果不依赖任何终端则为?,pts表示虚拟终端
STAT字段
进程的状态:
D uninterruptible sleep (usually IO)
R running or runnable (on run queue)
S interruptible sleep (waiting for an event to complete)
T stopped by job control signal
t stopped by debugger during the tracing
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z defunct (“zombie”) process, terminated but not reaped by its parent
状态补充符:
<:high-priority (not nice to other users)
N:low-priority (nice to other users)
L:has pages locked into memory (for real-time and custom IO)
s:is a session leader
l:is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
+ :is in the foreground process group
常用操作
#查看当前用户下的所有进程ps u 或 ps -u
#查看root用户下的所有进程ps -uroot 或 ps -u root
#查看当前用户组下的所有进程ps g 或 ps -g
#查看所有进程[f输出详细信息]ps -ef 或 ps -Af
#查看所有可运行的进程[f输出详细信息]ps -ef r 或 ps -Af r
#查看进程1[-f显示详细信息]ps -f p1 或 ps -f p 1#查看进程1的所有子进程[-f显示详细信息]ps -f --ppid 1