shell 命令产生的各个字段的含义

来源:互联网 发布:年轻男装品牌知乎 编辑:程序博客网 时间:2024/05/16 19:31
(1)zxlei@zxlei:~/desktop$ ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.0   2872  1748 ?        Ss   17:35   0:01 /sbin/init
root         2  0.0  0.0      0     0 ?        S    17:35   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    17:35   0:00 [ksoftirqd/0]
root         4  0.0  0.0      0     0 ?        S    17:35   0:00 [migration/0]
root         5  0.0  0.0      0     0 ?        S    17:35   0:00 [watchdog/0]
root         6  0.0  0.0      0     0 ?        S    17:35   0:00 [migration/1]
root         7  0.0  0.0      0     0 ?        S    17:35   0:00 [ksoftirqd/1]
root         8  0.0  0.0      0     0 ?        S    17:35   0:00 [watchdog/1]
root         9  0.0  0.0      0     0 ?        S    17:35   0:00 [migration/2]
root        10  0.0  0.0      0     0 ?        S    17:35   0:00 [ksoftirqd/2]


字段的含义
USER:说明该程序是属于哪一个人的;
PID:该程序的代号;
%CPU:代表该程序使用了多少 CPU 资源;
%MEM:代表该程序使用了多少的 RAM;
VSZ, 占去的 ram 的大小( bytes );vsize  总虚拟内存大小, bytes字节(包含code+data+stack) 
RSS:进程使用的总物理内存数, Kbytes字节 
TTY:是否为登入者执行的程序?若为 tty1-tty6 则为本机登入者,若为 pts/?? 则为远程登入者执行的程序
STAT:该程序的状态
START:该程序开始的日期;
TIME:该程序运行的时间?
COMMAND:该程序的内容啦!


PROCESS STATE CODES
Here are the different values that the s, stat and state output specifiers
(header "STAT" or "S") will display to describe the state of a process.
D    Uninterruptible sleep (usually IO)
R    Running or runnable (on run queue)
S    Interruptible sleep (waiting for an event to complete)
T    Stopped, either by a job control signal or because it is being traced.
W    paging (not valid since the 2.6.xx kernel)
X    dead (should never be seen)
Z    Defunct ("zombie") process, terminated but not reaped by its parent.


For BSD formats and when the stat keyword is used, additional characters may
be displayed:
<    high-priority (not nice to other users)
N    low-priority (nice to other users)
L    has pages locked into memory (for real-time and custom IO)
s    is a session leader
l    is multi-threaded (using CLONE_THREAD, like NPTL pthreads do)
+    is in the foreground process group
翻译:
D    不可中断睡眠 (通常是在IO操作) 收到信号不唤醒和不可运行, 进程必须等待直到有中断发生
R   正在运行或可运行(在运行队列排队中)
S   可中断睡眠 (休眠中, 受阻, 在等待某个条件的形成或接受到信号)
T   已停止的 进程收到SIGSTOP, SIGSTP, SIGTIN, SIGTOU信号后停止运行
W   正在换页(2.6.内核之前有效)
 X   死进程 (未开启)
 Z   僵尸进程  进程已终止, 但进程描述符存在, 直到父进程调用wait4()系统调用后释放BSD风格的
 <   高优先级(not nice to other users)
 N   低优先级(nice to other users)
 L   页面锁定在内存(实时和定制的IO)
 s   一个信息头
 l   多线程(使用 CLONE_THREAD,像NPTL的pthreads的那样)

 +   在前台进程组

(2)zxlei@zxlei:~/desktop$ cat fstab

 <file system>  <mount point>    <type>        <options>                        <dump>   <pass>
proc                        /proc                  proc            nodev,noexec,nosuid          0              0
/dev/sda1               /                        ext2           errors=remount-ro             0              1

/dev/sda1 是 parition 所在位置。

/ 就是 mount point(本质就是一个目录) 所在位置

<type> :eg:ext2 是檔案系統格式

<option >:defaults 當然是系統預設值啦(其中包括﹕rw﹑suid﹑dev﹑ exec﹑auto﹑nouser﹑和 async)﹐除了它﹐我們還可以加入(或只選取)相關的屬性﹐諸如﹕                                       ro,noauto,grpquota,usrquota 等等﹐分別用“,”分開就是了。(具體內容請 man mount 然後看 -o 的說明)

<dump> :倒数第二个数字﹐是說這個 mount point 在進行 dump (一個備份程式)的時候﹐是否要進行備份﹐如果是 0 則不備份

<pass> :即最後的數字﹐是告訴系統在重新開機的時候進行檢測的次序﹐通常‘/’是永遠排第 1 的﹐其他設為 2 就可以了﹐如果是 0 就不進行檢測。



(3)zxlei@zxlei:~$ top


top - 18:12:13 up 10:40,  4 users,  load average: 1.17, 1.08, 1.08
Tasks: 235 total,   2 running, 232 sleeping,   1 stopped,   0 zombie
Cpu(s):  4.4%us,  1.5%sy,  0.0%ni, 84.9%id,  9.1%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   2752952k total,  2072624k used,   680328k free,    18884k buffers
Swap:  2928636k total,    13704k used,  2914932k free,  1468836k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                      
12682 zxlei     20   0 80792  17m  10m R   10  0.6   0:00.29 gnome-help                                   
 1333 root      20   0  102m  28m 9240 S    4  1.0  17:31.34 Xorg                                         
 2314 zxlei     25   5  424m  84m  35m S    3  3.1  20:37.85 chrome                                       
 2540 zxlei     20   0  110m  20m  11m S    2  0.7   0:45.49 gnome-terminal                               
 9331 zxlei     20   0  234m  88m  26m S    2  3.3   3:45.58 chrome                                       
 2095 zxlei     20   0 90176  23m  11m S    1  0.9   0:14.62 python                                       
 2131 zxlei      9 -11 98316 5180 3896 S    1  0.2   7:53.20 pulseaudio                                   
 2092 zxlei     20   0  4824 2080  708 S    1  0.1   0:01.74 dbus-daemon                                  
 2137 zxlei     20   0 73640  23m 7740 S    1  0.9   5:12.67 compiz                                       
 2255 zxlei     20   0 94084  13m 9596 S    1  0.5   4:15.60 clock-applet                                 
12666 zxlei     20   0  2620 1200  844 R    1  0.0   0:00.23 top                                          
 2084 zxlei     20   0 18768 2716 2144 S    0  0.1   0:06.76 ibus-daemon                                  
 2258 zxlei     20   0 96584  14m 9.8m S    0  0.5   0:03.65 indicator-apple                              
 2430 zxlei     20   0  348m  40m  10m S    0  1.5  66:56.42 chrome                                       
12385 zxlei     25   5  186m  37m  20m S    0  1.4   0:03.02 chrome                                       
    1 root      20   0  2868 1568 1184 S    0  0.1   0:01.28 init                                         
    2 root      20   0     0    0    0 S    0  0.0   0:00.00 kthreadd                                     
    3 root      20   0     0    0    0 S    0  0.0   0:01.10 ksoftirqd/0                                  
    4 root      RT   0     0    0    0 S    0  0.0   0:00.21 migration/0 

PID: 进程 ID

USER: 进程所有者的用户名 

PR:任务优先级

NI nice值。数值越小表示优先级越高,数值越大表示优先级越低 ,通常來說﹐一般行程的 nice 值都是 0﹐彼此在處理上的優先權都是平等的。

VIRT 进程使用的虚拟内存总量,单位:kb。

          VIRT=SWAP+RES 

                    RES 进程使用的、未被换出的物理内存大小,单位:kb。RES=CODE+DATA 

SHR 共享内存大小,单位:kb 

S 进程状态

D= 不可中断的睡眠状态 
R= 运行 
S= 睡眠 
T= 跟踪 / 停止 
Z= 僵尸进程

 %CPU 上次更新到现在的 CPU 时间占用百分比 

TIME+ 进程使用的 CPU 时间总计,精确到 1/100 秒 

COMMAND 命令名 / 命令行