原创,转账注明出处
############################################################## ps a 显示现行终端机下的所有程序,包括其他用户的程序。 2)ps -A 显示所有程序。 3)ps c 列出程序时,显示每个程序真正的指令名称,而不包含路径,参数或常驻服务的标示。 4)ps -e 此参数的效果和指定"A"参数相同。 5)ps e 列出程序时,显示每个程序所使用的环境变量。 6)ps f 用ASCII字符显示树状结构,表达程序间的相互关系。 7)ps -H 显示树状结构,表示程序间的相互关系。 8)ps -N 显示所有的程序,除了执行ps指令终端机下的程序之外。 9)ps s 采用程序信号的格式显示程序状况。 10)ps S 列出程序时,包括已中断的子程序资料。 11)ps -t 指定终端机编号,并列出属于该终端机的程序的状况。 12)ps u 以用户为主的格式来显示程序状况。 13)ps x 显示所有程序,不以终端机来区分。 ############################################################## 1.最常用命令 查看所有进程详细信息 ps -ef ps aux 2. ps -l 选项 详细列出进程flags ps -efl 3.清爽型 ps -Al ps -A -A 打印所有进程,comand 只包含名称,不包含路径 4.常用字段含义 字 段 含义 USER 进程所有者的用户名 PID 进程号 %CPU 进程自最近一次刷新以来所占用的CPU时间和总时间的百分比 %MEM 进程使用内存的百分比 VSZ 进程使用的虚拟内存大小,以K为单位 the size in kilobytes of the process in virtual memory RSS 驻留空间的大小。显示当前常驻内存的程序的K字节数。The real-memory (resident set) size of the process (in 1 KB units). TTY 进程相关的终端 ############################################################## STAT 进程状态,用下面的代码中的一个给出: D 不可中断 Uninterruptible sleep (usually IO) R 正在运行,或在队列中的进程 S 处于休眠状态 T 停止或被追踪 Z 僵尸进程 W 进入内存交换(从内核2.6开始无效) X 死掉的进程 < 高优先级 N 低优先级 L 有些页被锁进内存 s 包含子进程 + 位于后台的进程组; l 多线程,克隆线程 ############################################################## TIME 进程使用的总CPU时间 COMMAND 被执行的命令行 NI 进程的优先级值,较小的数字意味着占用较少的CPU时间 PRI 进程优先级。 PPID 父进程ID WCHAN 进程等待的内核事件名 ps -elf 会涉及到的列: ADDR (-l) Contains the segment number of the process stack, if normal; if a kernel process, the address of the preprocess data area. SZ (-l) The size in pages of the core image of the process. WCHAN(-l) The event for which the process or kernel thread is waiting or sleeping. For a kernel thread, this field is blank if the kernel thread is running. For a process, the wait channel is defined as the wait channel of the sleeping kernel thread if only one kernel thread is sleeping; otherwise a star is displayed.