查找和杀死指定的进程, 他们的选项和参数完全相同, 这里只是介绍pgrep
/> sleep 100&
1000
/> sleep 100&
1001
/> pgrep sleep
1000
1001
/> pgrep -d: sleep # -d定义多个进程之间的分隔符, 如果不定义则使用newline
1000:1001
/> pgrep -n sleep # -n表示如果该程序有多个进程,查找最新的.
1001
/> pgrep -o sleep # -o表示如果该程序有多个进程,查找最老的.
1000
/> pgrep -G root,oracle sleep # -G 表示进程的group id在-G后面的组列表中的进程会被考虑
1000
1001
/> pgrep -u root,oracle sleep # -u 表示进程的effetive user id在-u后面的组列表中的进程会被考虑
1000
1001
/> pgrep -U root,oracle sleep # -U 表示进程的real user id在-u后面的组列表中的进程会被考虑
1000
1001
/> pgrep -x sleep # -x 表示进程的名字必须完全匹配, 以上的例子均可以部分匹配
1000
1001
/> pgrep -x sle
/> pgrep -l sleep # -l 将不仅打印pid,也打印进程名
1000 sleep
1001 sleep
/> pgrep -lf sleep # -f 一般与-l合用, 将打印进程的参数
1000 sleep 100
1001 sleep 100
/> pgrep -f sleep -d, | xargs ps -fp
UID PID PPID C STIME TTY TIME CMD
root 1000 2138 0 06:11 pts/5 00:00:00 sleep 1000
root 1001 2138 0 06:11 pts/5 00:00:00 sleep 1000
7. fuser:
fuser -m /dev # 列出所有和/dev设备有染的进程pid.
fuser testfile # 列出和testfile有染的进程pid
fuser -u testfile # 列出和testfile有染的进程pid和userid
fuser -k testfile # 杀死和testfile有染的进程pid
8. mount: