---ps 命令

ps 的命令真复杂啊!

值得注意的是选项的 -e e 这两个是不同的

-e的选项和x的意思相当

而e 的意思是改变显示栏目内容了 

 我个人用单字母的比较多

ps f -eo pid,uid,gid,user,pgrp,command --cols=120

ps -u bill -U bill -o %c
显示bill的进程包括有控制终端和无控制终端的进程
如果当前用户是bill,那么只要ps x -o %c 就可以了

ps 显示用户自己的有终端的进程(前台和后台)
ps x 显示用户自己的全部进程包括有终端和无终端的进程
ps x -o %c 这个和上面的相同了只是显示的是程序的名字

树形显示你自己的进程
ps -xjf

树形显示全部的进程
ps -axjf

a: all user (including root user)(还包括内核里的线程用[]圈出), w/o it only currenty user's processes are used
x: with no control terminal process
j: 增加显示
$ps auxf
f : 树形显示进程, tree
h: 不显示标题头。

USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
.....
root 1049 0.0 0.0 49468 1132 ? Ss Jul30 0:00 /usr/sbin/sshd -D
root 24712 0.0 0.0 85708 2204 ? Ss 15:26 0:00 \_ sshd: bill [priv]
bill 24807 0.0 0.0 85844 976 ? S 15:26 0:01 | \_ sshd: bill@pts/2
bill 24808 0.0 0.0 31348 3216 pts/2 Ss+ 15:26 0:00 | \_ -sh
root 26108 0.0 0.0 85708 3744 ? Ss 18:31 0:00 \_ sshd: bill [priv]
bill 26203 0.0 0.0 85844 1852 ? S 18:31 0:02 | \_ sshd: bill@pts/1
bill 26204 0.0 0.0 31356 10664 pts/1 Ss 18:31 0:00 | \_ -sh
root 27306 0.0 0.0 23756 1348 pts/1 S 18:53 0:00 | \_ sudo -i
root 27307 0.0 0.0 26904 6144 pts/1 S 18:53 0:00 | \_ -bash
git 28199 0.0 0.0 59668 1720 pts/1 S 19:36 0:00 | \_ su - git
git 28202 0.0 0.0 26704 6008 pts/1 S 19:36 0:00 | \_ -su
git 32125 0.0 0.0 20052 1308 pts/1 R+ 21:35 0:00 | \_ ps auxf
root 32024 0.0 0.0 85712 3684 ? Ss 21:35 0:00 \_ sshd: git [priv]
git 32119 0.0 0.0 86240 2068 ? S 21:35 0:00 \_ sshd: git@notty
git 32120 1.5 0.0 9940 640 ? Ss 21:35 0:00 \_ git shell -c git-upload-pack 're
git 32121 0.0 0.0 9940 644 ? S 21:35 0:00 \_ git upload-pack repositories
git 32122 0.0 0.0 9164 1024 ? S 21:35 0:00 \_ git-upload-pack reposito

#kill all the processes which have the same terminal
skill -KILL -v pts/4
pkill -9 -t pts/3

原文地址:https://www.cnblogs.com/bzhao/p/3328222.html