关于pgrep pmap top ps命令

在做存储有关的事,所以这几个命令需要用,这里简单总结一下吧。

pgrep

由进程名得到进程PID,比如我要得到当前正在执行的bochs虚拟机的进程号

#pgrep bochs

13667

这个13667就是进程号

pmap

由进程号,得到这个进程号对应进程的存储映射

#pmap 13667

13667:   bochs -q -f bochsrc.bxrc
08048000   1548K r-x--  /usr/local/bin/bochs
081cb000      4K r----  /usr/local/bin/bochs
081cc000     80K rw---  /usr/local/bin/bochs
081e0000  23612K rw---    [ anon ]
0aa50000   1340K rw---    [ anon ]
41a6b000    124K r-x--  /usr/lib/ld-2.16.so
41a8a000      4K r----  /usr/lib/ld-2.16.so
41a8b000      4K rw---  /usr/lib/ld-2.16.so
41a93000   1724K r-x--  /usr/lib/libc-2.16.so
41c42000      8K r----  /usr/lib/libc-2.16.so
41c44000      4K rw---  /usr/lib/libc-2.16.so
41c45000     12K rw---    [ anon ]
41c4a000    248K r-x--  /usr/lib/libm-2.16.so
41c88000      4K r----  /usr/lib/libm-2.16.so
41c89000      4K rw---  /usr/lib/libm-2.16.so
41c8c000     12K r-x--  /usr/lib/libdl-2.16.so
41c8f000      4K r----  /usr/lib/libdl-2.16.so
41c90000      4K rw---  /usr/lib/libdl-2.16.so
41cd3000    112K r-x--  /usr/lib/libgcc_s-4.7.2-20121109.so.1
41cef000      4K r----  /usr/lib/libgcc_s-4.7.2-20121109.so.1
41cf0000      4K rw---  /usr/lib/libgcc_s-4.7.2-20121109.so.1
41ec7000    896K r-x--  /usr/lib/libstdc++.so.6.0.17
41fa7000     16K r----  /usr/lib/libstdc++.so.6.0.17
41fab000      8K rw---  /usr/lib/libstdc++.so.6.0.17
41fad000     24K rw---    [ anon ]
41fb5000   1232K r-x--  /usr/lib/libX11.so.6.3.0
420e9000      4K r----  /usr/lib/libX11.so.6.3.0
420ea000     12K rw---  /usr/lib/libX11.so.6.3.0
420ef000      8K r-x--  /usr/lib/libXau.so.6.0.0
420f1000      4K r----  /usr/lib/libXau.so.6.0.0
420f2000      4K rw---  /usr/lib/libXau.so.6.0.0
420f5000    128K r-x--  /usr/lib/libxcb.so.1.1.0
42115000      4K r----  /usr/lib/libxcb.so.1.1.0
42116000      4K rw---  /usr/lib/libxcb.so.1.1.0
42121000     64K r-x--  /usr/lib/libXext.so.6.4.0
42131000      4K r----  /usr/lib/libXext.so.6.4.0
42132000      4K rw---  /usr/lib/libXext.so.6.4.0
4222f000     16K r-x--  /usr/lib/libXfixes.so.3.1.0
42233000      4K r----  /usr/lib/libXfixes.so.3.1.0
42234000      4K rw---  /usr/lib/libXfixes.so.3.1.0
4286a000     32K r-x--  /usr/lib/libXrender.so.1.3.0
42872000      4K r----  /usr/lib/libXrender.so.1.3.0
42873000      4K rw---  /usr/lib/libXrender.so.1.3.0
42876000     36K r-x--  /usr/lib/libXrandr.so.2.2.0
4287f000      4K r----  /usr/lib/libXrandr.so.2.2.0
42880000      4K rw---  /usr/lib/libXrandr.so.2.2.0
42897000     36K r-x--  /usr/lib/libXcursor.so.1.0.2
428a0000      4K r----  /usr/lib/libXcursor.so.1.0.2
428a1000      4K rw---  /usr/lib/libXcursor.so.1.0.2
b38d4000  16388K rw---    [ anon ]
b48d5000     28K r--s-  /usr/lib/gconv/gconv-modules.cache
b48dc000     80K r----  /usr/share/locale/zh_CN/LC_MESSAGES/libc.mo
b48f0000  39576K rw---    [ anon ]
b6f96000   1432K r----  /usr/lib/locale/locale-archive
b70fc000    256K r----  /usr/lib/locale/locale-archive
b713c000   2048K r----  /usr/lib/locale/locale-archive
b733c000   4116K rw---    [ anon ]
b7743000    144K rw---    [ anon ]
b7767000      4K r-x--    [ anon ]
bfaeb000    132K rw---    [ stack ]
 total    95632K
这样

top

对当前运行进程信息进行动态,实时的展示


  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND      
  732 root      20   0  112m  67m  17m R  34.5  4.5  14:18.86 X            
 1115 root      20   0  203m  30m  20m R  17.1  2.0   7:19.48 kwin         
13917 root      20   0  128m  30m  20m R   3.0  2.1   0:01.75 ksnapshot    
13667 root      20   0 95636  47m 2468 S   2.0  3.1   0:40.59 bochs        
 1039 root      20   0  237m  54m  28m S   0.7  3.6   0:07.82 kded4        
13941 root      20   0 64992 8372 6992 S   0.7  0.5   0:00.12 backlighthelp
  291 root      20   0 87840  14m  13m S   0.3  0.9   0:02.04 systemd-journ
  419 root      16  -4 11092  952  800 S   0.3  0.1   0:00.19 auditd       
  435 dbus      20   0  4488 2352 1284 S   0.3  0.2   0:10.58 dbus-daemon  
  584 polkitd   20   0 61680 9.9m 3944 S   0.3  0.7   0:03.06 polkitd      
  600 root      20   0 13872 1304  984 S   0.3  0.1   0:22.94 VBoxService  
 1041 root      20   0  3852 1248 1068 S   0.3  0.1   0:00.04 gam_server   
 1046 root      20   0 92904  14m  10m S   0.3  1.0   0:00.46 kglobalaccel 
 1123 root      20   0  215m  25m  18m R   0.3  1.7   0:01.02 knotify4     
 1160 root      20   0  277m  33m  25m S   0.3  2.2   0:01.96 krunner      
 1165 root      20   0  263m  28m  18m S   0.3  1.9   0:00.57 kmix         
 1699 root      39  19 85564  15m  12m R   0.3  1.0   0:00.26 nepomukservic

可以看到top命令有几个字段,其中我比较关心的有

VIRT:虚存
RSS:常驻内存
SHR:共享内存

ps

对当前进程运行状态的快照

#ps aux

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.2   6456  3540 ?        Ss   4月14   0:01 /usr/lib/s
root         2  0.0  0.0      0     0 ?        S    4月14   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    4月14   0:02 [ksoftirqd
root         5  0.0  0.0      0     0 ?        S<   4月14   0:00 [kworker/0
root         7  0.0  0.0      0     0 ?        S<   4月14   0:00 [kworker/u
root         8  0.0  0.0      0     0 ?        S    4月14   0:00 [migration
root         9  0.0  0.0      0     0 ?        S    4月14   0:00 [rcu_bh]
root        10  0.0  0.0      0     0 ?        S    4月14   0:01 [rcu_sched
root        11  0.0  0.0      0     0 ?        S    4月14   0:00 [watchdog/
root        12  0.0  0.0      0     0 ?        S<   4月14   0:00 [cpuset]
root        13  0.0  0.0      0     0 ?        S<   4月14   0:00 [khelper]
root        14  0.0  0.0      0     0 ?        S    4月14   0:00 [kdevtmpfs
root        15  0.0  0.0      0     0 ?        S<   4月14   0:00 [netns]
root        16  0.0  0.0      0     0 ?        S    4月14   0:00 [bdi-defau
root        17  0.0  0.0      0     0 ?        S<   4月14   0:00 [kintegrit
root        18  0.0  0.0      0     0 ?        S<   4月14   0:00 [kblockd]
root        19  0.0  0.0      0     0 ?        S<   4月14   0:00 [ata_sff]
root        20  0.0  0.0      0     0 ?        S    4月14   0:00 [khubd]
root        21  0.0  0.0      0     0 ?        S<   4月14   0:00 [md]
root        24  0.0  0.0      0     0 ?        S    4月14   0:00 [kswapd0]
root        25  0.0  0.0      0     0 ?        SN   4月14   0:00 [ksmd]
root        26  0.0  0.0      0     0 ?        SN   4月14   0:01 [khugepage
root        27  0.0  0.0      0     0 ?        S    4月14   0:00 [fsnotify_
root        28  0.0  0.0      0     0 ?        S<   4月14   0:00 [crypto]
root        36  0.0  0.0      0     0 ?        S<   4月14   0:00 [kthrotld]
root        37  0.0  0.0      0     0 ?        S    4月14   0:00 [kworker/u
root        38  0.0  0.0      0     0 ?        S    4月14   0:00 [scsi_eh_0
root        39  0.0  0.0      0     0 ?        S    4月14   0:00 [scsi_eh_1
root        40  0.0  0.0      0     0 ?        S    4月14   0:00 [scsi_eh_2
root        43  0.0  0.0      0     0 ?        S<   4月14   0:00 [kpsmoused
root        44  0.0  0.0      0     0 ?        S<   4月14   0:00 [deferwq]
root        45  0.0  0.0      0     0 ?        S    4月14   0:00 [kworker/u
root        51  0.0  0.0      0     0 ?        S    4月14   0:00 [kauditd]
root       147  0.0  0.0      0     0 ?        S<   4月14   0:00 [kworker/0
root       190  0.0  0.0      0     0 ?        S<   4月14   0:00 [kdmflush]
root       192  0.0  0.0      0     0 ?        S<   4月14   0:00 [kdmflush]
root       239  0.0  0.0      0     0 ?        S    4月14   0:02 [jbd2/dm-1
root       240  0.0  0.0      0     0 ?        S<   4月14   0:00 [ext4-dio-
root       289  0.0  0.1   5820  1732 ?        Ss   4月14   0:00 /usr/lib/s
root       291  0.0  0.9  87840 14388 ?        Ss   4月14   0:02 /usr/lib/s
root       346  0.0  0.0   5816  1104 ?        S    4月14   0:00 /usr/lib/s
root       347  0.0  0.0   5816  1100 ?        S    4月14   0:00 /usr/lib/s
root       363  0.0  0.0      0     0 ?        S<   4月14   0:00 [iprt]
root       384  0.0  0.0      0     0 ?        S    4月14   0:00 [jbd2/sda1
root       385  0.0  0.0      0     0 ?        S<   4月14   0:00 [ext4-dio-
root       418  0.0  0.7  23704 12096 ?        Ss   4月14   0:00 /usr/bin/p
root       419  0.0  0.0  11092   952 ?        S<sl 4月14   0:00 /sbin/audi
root       422  0.0  0.1   4596  1824 ?        Ss   4月14   0:00 /usr/sbin/
root       426  0.0  0.0  10052  1432 ?        Ss   4月14   0:00 /usr/sbin/
root       428  0.0  0.0   9988  1108 ?        Ss   4月14   0:00 /usr/bin/a
root       430  0.0  0.0   9988  1108 ?        Ss   4月14   0:00 /usr/bin/a
root       432  0.0  0.1   4024  1660 ?        Ss   4月14   0:00 /usr/lib/s
root       434  0.0  0.1  30524  1628 ?        Ssl  4月14   0:00 /sbin/rsys
dbus       435  0.0  0.1   4488  2352 ?        Ss   4月14   0:10 /bin/dbus-
rtkit      436  0.0  0.0  21204  1020 ?        SNsl 4月14   0:01 /usr/libex
root       451  0.0  0.0   3148   800 ?        Ss   4月14   0:00 /usr/sbin/
root       462  0.0  0.0   2524   304 ?        Ss   4月14   0:03 /usr/sbin/
root       469  0.0  0.0   2312   796 ?        Ss   4月14   0:00 /usr/sbin/
root       478  0.0  0.0   7660  1436 ?        Ss   4月14   0:00 /usr/sbin/
root       480  0.0  0.0  11528   780 ?        S<sl 4月14   0:00 /sbin/audi
root       485  0.0  0.0   3408   764 ?        S<   4月14   0:00 /usr/sbin/
root       490  0.0  0.0      0     0 ?        S<   4月14   0:00 [iscsi_eh]
chrony     497  0.0  0.0   3228  1268 ?        S    4月14   0:00 /usr/sbin/
root       511  0.0  0.0      0     0 ?        S<   4月14   0:00 [ib_mcast]
root       519  0.0  0.0      0     0 ?        S<   4月14   0:00 [ib_cm]
root       522  0.0  0.0      0     0 ?        S<   4月14   0:00 [iw_cm_wq]
root       523  0.0  0.0      0     0 ?        S<   4月14   0:00 [ib_addr]
root       525  0.0  0.0      0     0 ?        S<   4月14   0:00 [rdma_cm]
root       528  0.0  0.0      0     0 ?        S<   4月14   0:00 [cxgb4]
root       530  0.0  0.0      0     0 ?        S<   4月14   0:00 [cnic_wq]
root       531  0.0  0.0      0     0 ?        S<   4月14   0:00 [bnx2i_thr
root       535  0.0  0.0  28080   308 ?        Ssl  4月14   0:00 iscsiuio
root       541  0.0  0.0   2828   416 ?        Ss   4月14   0:03 iscsid
root       542  0.0  0.2   3288  3140 ?        S<Ls 4月14   0:17 iscsid
root       545  0.0  0.3  42576  5512 ?        Ssl  4月14   0:00 /usr/sbin/
polkitd    584  0.0  0.6  61680 10124 ?        Ssl  4月14   0:03 /usr/lib/p
root       600  0.0  0.0  13872  1304 ?        Sl   4月14   0:22 /usr/sbin/
root       615  0.0  0.1   7888  2760 ?        S    4月14   0:00 /usr/sbin/
root       617  0.0  0.1   4892  1804 ?        Ss   4月14   0:00 /usr/sbin/
root       654  0.0  0.6  18544 10100 ?        S    4月14   0:00 /sbin/dhcl
rpc        674  0.0  0.0   2752   728 ?        Ss   4月14   0:00 /sbin/rpcb
root       685  0.0  0.0   4228   940 ?        Ss   4月14   0:00 /usr/bin/k
root       717  0.0  0.1  20748  2008 ?        Ss   4月14   0:07 /usr/sbin/
root       732  1.0  4.4 114452 68368 tty1     Rs+  4月14  14:36 /usr/bin/X
root       733  0.0  0.1  13876  1868 ?        Ss   4月14   0:02 sendmail:
root       756  0.0  0.3  31456  4660 ?        Ss   4月14   0:07 /usr/sbin/
smmsp      758  0.0  0.1  13360  1624 ?        Ss   4月14   0:00 sendmail:
root       762  0.0  0.1  31456  2292 ?        S    4月14   0:00 /usr/sbin/
root       773  0.0  0.2  15192  3444 ?        Ss   4月14   0:19 /usr/sbin/
root       780  0.0  0.2   9952  3472 ?        S    4月14   0:00 -:0      
root       795  0.0  0.0   6984  1388 ?        Ss   4月14   0:00 /bin/sh /u
root       809  0.0  0.0   3616   384 ?        S    4月14   0:00 dbus-launc
root       810  0.0  0.1   4936  1572 ?        Ss   4月14   0:02 /bin/dbus-
root       872  0.0  0.2  31760  3668 ?        Sl   4月14   0:00 /usr/libex
root       875  0.0  0.1  31736  2692 ?        Sl   4月14   0:00 /usr/libex
root       952  0.0  0.1  11096  1696 ?        Sl   4月14   0:00 /usr/bin/V
root       962  0.0  0.1  11152  1604 ?        Sl   4月14   0:00 /usr/bin/V
root       968  0.0  0.0  11084  1212 ?        Sl   4月14   0:00 /usr/bin/V
root       974  0.2  0.0  11736  1440 ?        Sl   4月14   3:29 /usr/bin/V
root      1001  0.0  0.0   9712   496 ?        Ss   4月14   0:00 /usr/bin/s
root      1035  0.0  0.0   2044    56 ?        S    4月14   0:00 /usr/libex
root      1036  0.0  0.3  64964  5388 ?        Ss   4月14   0:00 kdeinit4:
root      1037  0.0  0.5  77700  8772 ?        S    4月14   0:00 klauncher
root      1039  0.0  3.6 243424 55836 ?        Sl   4月14   0:07 kded4
root      1041  0.0  0.0   3852  1248 ?        S    4月14   0:00 /usr/libex
root      1046  0.0  0.9  92904 14696 ?        S    4月14   0:00 /usr/bin/k
root      1048  0.0  0.9  91676 14332 ?        S    4月14   0:00 /usr/bin/k
root      1052  0.0  0.9 113288 15072 ?        S    4月14   0:00 /usr/bin/k
root      1053  0.0  0.2  29340  3348 ?        Ssl  4月14   0:00 /usr/libex
root      1074  0.0  0.0   2180   204 ?        S    4月14   0:00 kwrapper4
root      1081  0.0  1.1 156424 17092 ?        Sl   4月14   0:00 ksmserver
root      1100  0.0  0.2  42416  3652 ?        Ssl  4月14   0:00 /usr/lib/u
root      1115  0.5  2.0 207928 31136 ?        Sl   4月14   7:27 kwin -sess
root      1123  0.0  1.6 220552 26048 ?        Sl   4月14   0:01 /usr/bin/k
root      1127  0.0  5.3 383424 82900 ?        Sl   4月14   0:47 /usr/bin/p
root      1132  0.0  0.0   2740   900 ?        S    4月14   0:00 ksysguardd
root      1135  0.0  0.8  91800 13168 ?        S    4月14   0:00 /usr/bin/k
root      1137  0.0  0.3  33144  5120 ?        Sl   4月14   0:00 /usr/libex
root      1158  0.0  0.4  78032  6788 ?        Sl   4月14   0:00 /usr/bin/n
root      1160  0.0  2.2 283656 34076 ?        Sl   4月14   0:01 /usr/bin/k
root      1162  0.0  1.3 168264 20868 ?        SNl  4月14   0:00 /usr/bin/n
root      1165  0.0  1.8 270168 28912 ?        Sl   4月14   0:00 /usr/bin/k
root      1167  0.0  0.9  92892 13880 ?        S    4月14   0:00 /usr/bin/n
root      1171  0.1  1.8 144508 29108 ?        Sl   4月14   1:29 konsole -s
root      1175  0.0  0.2   8360  3136 pts/0    Ss   4月14   0:02 /bin/bash
root      1241  0.0  2.3  53316 36272 ?        SNl  4月14   0:13 /usr/bin/v
root      1245  0.0  2.0 202428 32160 ?        Sl   4月14   0:01 /usr/bin/d
root      1248  0.0  2.0 202136 31728 ?        Sl   4月14   0:01 /usr/bin/d
root      1259  0.0  0.3  44944  4920 ?        S    4月14   0:00 /usr/bin/a
root      1289  0.0  0.4  34424  6816 ?        Sl   4月14   0:00 /usr/bin/x
root      1324  0.0  0.6 102736  9944 ?        S<l  4月14   0:00 /usr/bin/p
root      1352  0.0  0.1  42568  2888 ?        Sl   4月14   0:00 /usr/libex
root      1356  0.0  1.0 102540 16616 ?        Sl   4月14   0:00 /usr/libex
root      1362  0.0  0.0   3660  1364 ?        S    4月14   0:00 /bin/dbus-
root      1368  0.0  0.1  17560  2868 ?        Sl   4月14   0:00 /usr/libex
root      1419  0.0  1.0  92204 16408 ?        S    4月14   0:00 /usr/bin/k
root      1651  0.0  0.6  58776 10492 ?        Sl   4月14   0:06 /usr/bin/i
root      1659  0.0  0.2  31620  3356 ?        Sl   4月14   0:00 /usr/libex
root      1661  0.0  0.8  71004 13688 ?        Sl   4月14   0:00 /usr/libex
root      1664  0.0  0.3  56092  5424 ?        Sl   4月14   0:00 /usr/libex
root      1684  0.0  0.2  18444  3088 ?        Sl   4月14   0:01 /usr/libex
root      1699  0.0  1.0  85564 15436 ?        SN   4月14   0:00 /usr/bin/n
root      1700  0.0  0.9  90520 15308 ?        SNl  4月14   0:00 /usr/bin/n
root      1701  0.0  1.2 108156 19960 ?        SNl  4月14   0:00 /usr/bin/n
root      1702  0.0  0.9  80784 13984 ?        SN   4月14   0:00 /usr/bin/n
root      1976  0.0  1.0 148016 16924 ?        S    4月14   0:00 /usr/libex
root     11182  0.0  0.0      0     0 ?        S    08:02   0:00 [flush-253:
root     13206  0.1  1.9 146152 30128 ?        Sl   09:11   0:14 konsole --w
root     13210  0.0  0.2   8324  3092 pts/2    Ss+  09:11   0:00 /bin/bash
root     13667  2.0  3.1  95636 48304 pts/0    S+   10:54   0:41 bochs -q -f
root     13755  0.0  0.0      0     0 ?        S    11:10   0:00 [kworker/0:
root     13794  0.0  0.1   8244  2856 pts/3    Ss   11:17   0:00 /bin/bash
root     13895  0.0  0.0      0     0 ?        S    11:20   0:00 [kworker/0:
root     13945  0.0  0.0      0     0 ?        S    11:27   0:00 [kworker/0:
root     13967  0.0  0.0   6740  1128 pts/3    R+   11:27   0:00 ps aux

可以看到有很多字段,同样,我比较关心的有

VSZ:虚存
RSS:实际占用物理内存

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值