什么是进程:
 下图所示是进程的生命周期:   简单理解:父进程退出了子进程没有退出,那么这些子进程就没有父进程来管理了,就变成僵尸进程。
进程的属性:
 使用ps查看进程工具:
 例2:常用的选项组合是 ps -aux
[root@docker abc]# ps -aux | head
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.2 125352 3888 ? Ss 13:33 0:00 /usr/lib/systemd/systemd --switched-root --system --deserialize 22
root 2 0.0 0.0 0 0 ? S 13:33 0:00 [kthreadd]
root 4 0.0 0.0 0 0 ? S< 13:33 0:00 [kworker/0:0H]
root 6 0.0 0.0 0 0 ? S 13:33 0:00 [ksoftirqd/0]
root 7 0.0 0.0 0 0 ? S 13:33 0:00 [migration/0]
root 8 0.0 0.0 0 0 ? S 13:33 0:00 [rcu_bh]
root 9 0.0 0.0 0 0 ? R 13:33 0:00 [rcu_sched]
root 10 0.0 0.0 0 0 ? S< 13:33 0:00 [lru-add-drain]
root 11 0.0 0.0 0 0 ? S 13:33 0:00 [watchdog/0]
注:最后一列 [xxxxx] 使用方括号括起来的进程是内核态的进程。没有括起来的是用户态的进程。
上面的参数输出每列含义:  5个基本状态后,还可以加一些字母,比如:Ss、R+。如下图 
 例1:查看进程状态
编辑a.txt:
[root@docker abc]# vim a.txt
在另一个终端执行:
[root@docker abc]# ps -aux | grep a.txt #查看状态, S表示睡眠状态
root 2065 0.0 0.2 149448 5128 pts/0 S+ 15:55 0:00 vim a.txt
root 2073 0.0 0.0 112728 984 pts/1 S+ 15:56 0:00 grep --color=auto a.txt
在vim a.txt这个终端上 按下 :ctrl+z
[1]+ 已停止 vim a.txt
在另个终端执行:
[root@docker abc]# ps -aux | grep a.txt #查看状态,S表示停止状态
root 2065 0.0 0.2 149448 5128 pts/0 T 15:55 0:00 vim a.txt
root 2089 0.0 0.0 112728 984 pts/1 R+ 16:04 0:00 grep --color=auto a.txt
 例2:D 不可中断状态 [root@docker abc]# tar -zcvf a.tar.gz /usr/
#然后在另一个终端不断查看状态,由S+,R+变成D+
[root@docker abc]# ps -aux | grep tar
root 1109 0.0 0.0 0 0 ? S< 13:33 0:00 [target_completi]
root 2104 0.0 0.0 112728 972 pts/0 R+ 16:17 0:00 grep --color=auto tar
[root@docker abc]# ps -aux | grep tar
root 1109 0.0 0.0 0 0 ? S< 13:33 0:00 [target_completi]
root 2105 1.6 0.0 123576 1468 pts/1 S+ 16:17 0:00 tar -zcvf a.tar.gz /usr/
root 2108 0.0 0.0 112728 972 pts/0 R+ 16:18 0:00 grep --color=auto tar
[root@docker abc]# ps -aux | grep tar
root 1109 0.0 0.0 0 0 ? S< 13:33 0:00 [target_completi]
root 2105 1.6 0.0 123576 1468 pts/1 D+ 16:17 0:00 tar -zcvf a.tar.gz /usr/
ps常用的参数 :ps -ef
[root@docker abc]# ps -ef | grep tar
root 1109 2 0 13:33 ? 00:00:00 [target_completi]
root 2116 1606 0 16:22 pts/0 00:00:00 grep --color=auto tar
|