ps aux / ps -aux / ps -ef 区别

Linux的ps命令是Process Status的缩写
ps命令用来列出系统中当前运行的那些进程
ps列出当前进程的快照
就是执行ps命令的那个时刻的那些进程
如果想要动态的显示进程信息,使用top命令
 
查看当前进程
ps 是最基本同时也是非常强大的进程查看命令
确定有哪些进程正在运行和运行的状态、进程是否结束、进程有没有僵死、哪些进程占用了过多的资源等
ps 提供的查看结果并不动态连续的
如果想对进程时间监控用 top 工具
 
kill 命令用于杀死进程
linux上进程有5种状态:
1. 运行(正在运行或在运行队列中等待)
2. 中断(休眠中, 受阻, 在等待某个条件的形成或接受到信号)
3. 不可中断(收到信号不唤醒和不可运行, 进程必须等待直到有中断发生)
4. 僵死(进程已终止, 但进程描述符存在, 直到父进程调用wait4()系统调用后释放)
5. 停止(进程收到SIGSTOP, SIGSTP, SIGTIN, SIGTOU信号后停止运行运行)
ps工具标识进程的5种状态码:
D 不可中断 uninterruptible sleep (usually IO)
R 运行 runnable (on run queue)
S 中断 sleeping
T 停止 traced or stopped
Z 僵死 a defunct (”zombie”) process

具体参数可以参考man ps或

ps aux和ps –aux的区别
及ps aux和ps –ef的区别

1. ps aux和ps –aux
man ps 之后得到的结果:
ps displays information about a selection of the active processes. If you want a repetitive update of the selection and the displayed information, use top(1) instead.
Note that "ps -aux" is distinct from "ps aux". The POSIX and UNIX standards require that "ps -aux" print all processes owned by a user named "x", as well as printing all processes that would be selected by the -a option. If the user named "x" does not exist, this ps may interpret the command as "ps aux" instead and print a warning.
This behavior is intended to aid in transitioning old scripts and habits. It is fragile, subject to change, and thus should not be relied upon.
请注意 ps -aux 不同于 ps aux
POSIX和UNIX的标准要求 ps -aux 打印用户名为 x 的用户的所有进程,以及打印所有将由-a选项选择的过程
如果用户名为"x"不存在,ps的将会解释为 ps aux 且会打印一个警告
这种行为是为了帮助转换旧脚本和习惯 是脆弱的,即将更改,因此不应依赖
 
如果运行ps -aux >/dev/null,那么你就会得到下面这行警告信息
Warning: bad ps syntax, perhaps a bogus

综上
使用时两者之间直接选择ps aux

2. ps aux 和ps -ef
风格不同aux是BSD风格
-ef是System V风格
一个影响使用的区别是aux会截断command列
-ef不会 当结合grep时这种区别会影响到结果
综上
以上三个命令推荐使用:ps –ef