ps -aux

~]# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.2   2900   852 ?        Ss   11:49   0:01 /sbin/init
root         2  0.0  0.0      0     0 ?        S    11:49   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    11:49   0:00 [migration/0]
root         4  0.0  0.0      0     0 ?        S    11:49   0:11 [ksoftirqd/0]
root         5  0.0  0.0      0     0 ?        S    11:49   0:00 [migration/0]
root         6  0.0  0.0      0     0 ?        S    11:49   0:00 [watchdog/0]
root         7  0.0  0.0      0     0 ?        S    11:49   0:04 [events/0]
root         8  0.0  0.0      0     0 ?        S    11:49   0:00 [cgroup]
root         9  0.0  0.0      0     0 ?        S    11:49   0:00 [khelper]

与 ps  -elf 大同小异,显示的信息基本上是一样的。ps命令还有更多的用法。

PID :进程的id,这个id很有用,在linux中内核管理进程就得靠pid来识别和管理某一个程,比如我想终止某一个进程,则用 ‘kill  进程的pid 有时并不能杀掉,则需要加一个-9选项了 kill  -9  进程pid

STAT :表示进程的状态,进程状态分为以下几种(不要求记住,但要了解)

D 不能中断的进程(通常为IO)

R 正在运行中的进程

S 已经中断的进程,通常情况下,系统中大部分进程都是这个状态

T 已经停止或者暂停的进程,如果我们正在运行一个命令,比如说 sleep 10 如果我们按一下ctrl -z 让他暂停,那么我们用ps查看就会显示T这个状态

W 这个好像是说,从内核2.6xx 以后,表示为没有足够的内存页分配

X 已经死掉的进程(这个好像从来不会出现)

Z 僵尸进程,杀不掉,打不死的垃圾进程,占系统一小点资源,不过没有关系。如果太多,就有问题了。一般不会出现。

< 高优先级进程

N 低优先级进程

L 在内存中被锁了内存分页

s 主进程

l 多线程进程

+ 代表在前台运行的进程

经常会连同管道符一起使用,用来查看某个进程或者它的数量。

[root@localhost ~]# ps aux |grep -c mingetty
6
[root@localhost ~]# ps aux |grep  mingetty
root       952  0.0  0.1   2008   440 tty2     Ss+  11:49   0:00  /sbin/mingetty /dev/tty2
root       954  0.0  0.1   2008   440 tty3     Ss+  11:49   0:00  /sbin/mingetty /dev/tty3
root       956  0.0  0.1   2008   440 tty4     Ss+  11:49   0:00  /sbin/mingetty /dev/tty4
root       958  0.0  0.1   2008   436 tty5     Ss+  11:49   0:00  /sbin/mingetty /dev/tty5
root       960  0.0  0.1   2008   444 tty6     Ss+  11:49   0:00  /sbin/mingetty /dev/tty6
root      8440  0.0  0.2   5984   732 pts/3    S+   17:12   0:00  grep mingetty

上面的6不对,需要减掉1,因为使用grep命令时,grep命令本身也算作了一个。

posted on 2015-02-04 15:20  后进后退  阅读(352)  评论(0编辑  收藏  举报