Linux /proc、/dev Principle

Andrew.Hann發表於2014-07-31

目錄

1. /proc簡介
2. 核心機制相關
3. 程式資訊
4. 硬體裝置相關
5. 系統資訊
6. /dev簡介
7. 記憶體相關 

 

1. /proc簡介

在linux的根目錄下有一個/proc目錄,/proc檔案系統是一個虛擬檔案系統,通過它可以使用一種新的方法在Linux核心空間和使用者空間之間進行通訊。在/proc檔案系統中,我們可以將對虛擬檔案的讀寫作為與核心中實體進行通訊的一種手段,但是與普通檔案不同的是,這些虛擬檔案的內容都是動態建立的(即在我們執行指令的那一剎那才產生的)

/proc檔案系統包含了:

1. 一些目錄(用作組織資訊的方式)
例如linux對於當前執行中的每一個程式都在/proc目錄下建立一個目錄(目錄名就是process-id),例如init的程式號是1,則目錄名也是1
2. 虛擬檔案
虛擬檔案可以向使用者呈現核心中的一些資訊,也可以用作一種從使用者空間向核心傳送資訊的手段

執行: ll /proc,我們可以得到如下結果

dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 1
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 10
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 1024
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 11
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 12
dr-xr-xr-x.  8 apache    apache       0 Jul 30 05:08 12016
dr-xr-xr-x.  8 apache    apache       0 Jul 30 05:08 12017
dr-xr-xr-x.  8 apache    apache       0 Jul 30 05:08 12018
dr-xr-xr-x.  8 apache    apache       0 Jul 30 05:08 12019
dr-xr-xr-x.  8 apache    apache       0 Jul 30 05:08 12020
dr-xr-xr-x.  8 apache    apache       0 Jul 30 05:08 12021
dr-xr-xr-x.  8 apache    apache       0 Jul 30 05:08 12022
dr-xr-xr-x.  8 apache    apache       0 Jul 30 05:08 12023
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 13
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 1329
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 1349
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 14
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 147
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 148
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 149
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 15
dr-xr-xr-x.  8 root      root         0 Jul 30 00:14 15269
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 154
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 155
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 16
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 1613
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 1638
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 17
dr-xr-xr-x.  8 root      root         0 Jul 30 17:07 17975
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 18
dr-xr-xr-x.  8 root      root         0 Jul 30 17:12 18170
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 19
dr-xr-xr-x.  8 root      root         0 Jul 30 19:46 19703
dr-xr-xr-x.  8 root      root         0 Jul 30 20:04 19846
dr-xr-xr-x.  8 root      root         0 Jul 30 20:04 19851
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 2
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 20
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 21
dr-xr-xr-x.  8 postfix   postfix      0 Jul 31 01:36 21833
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 22
dr-xr-xr-x.  8 root      root         0 Jul 31 01:36 22122
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 23
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 24
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 25
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 254
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 255
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 256
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 257
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 258
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 259
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 26
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 260
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 261
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 262
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 263
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 264
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 265
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 266
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 267
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 268
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 269
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 27
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 270
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 271
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 272
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 273
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 274
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 275
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 276
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 277
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 278
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 279
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 28
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 280
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 281
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 282
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 283
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 29
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 3
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 30
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 31
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 32
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 342
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 343
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 368
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 37
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 38
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 4
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 40
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 41
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 434
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 5
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 512
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 6
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 7
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 71
dr-xr-xr-x.  8 dbus      dbus         0 Jul 28 20:32 7682
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 7693
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 7699
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 7716
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 7718
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 7743
dr-xr-xr-x.  8 haldaemon haldaemon    0 Jul 28 20:32 7752
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 7753
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 7799
dr-xr-xr-x.  8 haldaemon haldaemon    0 Jul 28 20:32 7803
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 7820
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 7838
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 7884
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 7900
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 8
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 8016
dr-xr-xr-x.  8 postfix   postfix      0 Jul 28 20:32 8023
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 8040
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 8048
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 8058
dr-xr-xr-x.  8 root      root         0 Jul 28 20:33 8072
dr-xr-xr-x.  8 root      root         0 Jul 28 20:33 8089
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 8112
dr-xr-xr-x.  8 root      root         0 Jul 28 20:33 8117
dr-xr-xr-x.  8 root      root         0 Jul 28 20:33 8119
dr-xr-xr-x.  8 root      root         0 Jul 28 20:33 8121
dr-xr-xr-x.  8 root      root         0 Jul 28 20:33 8125
dr-xr-xr-x.  8 root      root         0 Jul 28 20:33 8128
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 8136
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 8139
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 8155
dr-xr-xr-x.  8 gdm       gdm          0 Jul 28 20:32 8225
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 8231
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 8273
dr-xr-xr-x.  8 rtkit     rtkit        0 Jul 28 20:32 8284
dr-xr-xr-x.  8 root      root         0 Jul 28 20:32 8290
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 866
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 8926
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 8936
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 8944
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 8945
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 8959
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 8968
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 8969
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 8974
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 8981
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 8982
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 8996
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 8997
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 8999
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 9
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9005
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9007
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9009
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9011
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9015
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9016
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9018
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9019
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9020
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9023
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9024
dr-xr-xr-x.  8 root      root         0 Jul 30 05:08 9028
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9031
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9032
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9036
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9039
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9046
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9052
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9054
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9061
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9065
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9066
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9067
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9072
dr-xr-xr-x.  8 root      root         0 Jul 30 05:08 9073
dr-xr-xr-x.  8 root      root         0 Jul 30 05:08 9082
dr-xr-xr-x.  8 root      root         0 Jul 28 20:39 9118
dr-xr-xr-x.  8 root      root         0 Jul 28 20:40 9124
dr-xr-xr-x.  8 root      utmp         0 Jul 28 20:40 9125
dr-xr-xr-x.  8 root      root         0 Jul 28 20:40 9126
dr-xr-xr-x.  8 root      root         0 Jul 28 20:43 9160
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 936
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 937
dr-xr-xr-x.  8 root      root         0 Jul 28 21:27 9474
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 974
dr-xr-xr-x.  8 root      root         0 Jul 28 20:31 975
dr-xr-xr-x.  8 root      root         0 Jul 28 22:05 9779
dr-xr-xr-x. 10 root      root         0 Jul 28 20:32 acpi
dr-xr-xr-x.  5 root      root         0 Jul 31 01:36 asound
-r--r--r--.  1 root      root         0 Jul 31 01:36 buddyinfo
dr-xr-xr-x.  6 root      root         0 Jul 28 20:31 bus
-r--r--r--.  1 root      root         0 Jul 31 01:36 cgroups
-r--r--r--.  1 root      root         0 Jul 31 01:36 cmdline
-r--r--r--.  1 root      root         0 Jul 31 01:36 cpuinfo
-r--r--r--.  1 root      root         0 Jul 31 01:36 crypto
-r--r--r--.  1 root      root         0 Jul 31 01:36 devices
-r--r--r--.  1 root      root         0 Jul 31 01:36 diskstats
-r--r--r--.  1 root      root         0 Jul 31 01:36 dma
dr-xr-xr-x.  2 root      root         0 Jul 31 01:36 driver
-r--r--r--.  1 root      root         0 Jul 31 01:36 execdomains
-r--r--r--.  1 root      root         0 Jul 31 01:36 fb
-r--r--r--.  1 root      root         0 Jul 31 01:36 filesystems
dr-xr-xr-x.  5 root      root         0 Jul 31 01:36 fs
-r--r--r--.  1 root      root         0 Jul 31 01:36 interrupts
-r--r--r--.  1 root      root         0 Jul 31 01:36 iomem
-r--r--r--.  1 root      root         0 Jul 31 01:36 ioports
dr-xr-xr-x.  2 root      root         0 Jul 31 01:36 ipmi
dr-xr-xr-x. 55 root      root         0 Jul 31 01:36 irq
-r--r--r--.  1 root      root         0 Jul 31 01:36 kallsyms
-r--------.  1 root      root      4096 Jul 31 01:36 kcore
-r--r--r--.  1 root      root         0 Jul 31 01:36 keys
-r--r--r--.  1 root      root         0 Jul 31 01:36 key-users
-r--------.  1 root      root         0 Jul 28 20:32 kmsg
-r--------.  1 root      root         0 Jul 31 01:36 kpagecount
-r--------.  1 root      root         0 Jul 31 01:36 kpageflags
-r--r--r--.  1 root      root         0 Jul 31 01:36 loadavg
-r--r--r--.  1 root      root         0 Jul 31 01:36 locks
-r--r--r--.  1 root      root         0 Jul 28 20:32 mdstat
-r--r--r--.  1 root      root         0 Jul 28 20:32 meminfo
-r--r--r--.  1 root      root         0 Jul 31 01:36 misc
-r--r--r--.  1 root      root         0 Jul 31 01:36 modules
lrwxrwxrwx.  1 root      root        11 Jul 31 01:36 mounts -> self/mounts
dr-xr-xr-x.  3 root      root         0 Jul 31 01:36 mpt
-r--r--r--.  1 root      root         0 Jul 31 01:36 mtd
-rw-r--r--.  1 root      root         0 Jul 28 20:32 mtrr
lrwxrwxrwx.  1 root      root         8 Jul 31 01:36 net -> self/net
-r--r--r--.  1 root      root         0 Jul 31 01:36 pagetypeinfo
-r--r--r--.  1 root      root         0 Jul 31 01:36 partitions
-r--r--r--.  1 root      root         0 Jul 31 01:36 sched_debug
-r--r--r--.  1 root      root         0 Jul 31 01:36 schedstat
dr-xr-xr-x.  4 root      root         0 Jul 31 01:36 scsi
lrwxrwxrwx.  1 root      root        64 Jul 31 00:01 self -> 22122
-rw-r--r--.  1 root      root         0 Jul 31 01:36 slabinfo
-r--r--r--.  1 root      root         0 Jul 31 01:36 softirqs
-r--r--r--.  1 root      root         0 Jul 28 20:32 stat
-r--r--r--.  1 root      root         0 Jul 31 01:36 swaps
dr-xr-xr-x.  1 root      root         0 Jul 28 20:31 sys
--w-------.  1 root      root         0 Jul 31 01:36 sysrq-trigger
dr-xr-xr-x.  2 root      root         0 Jul 31 01:36 sysvipc
-r--r--r--.  1 root      root         0 Jul 31 01:36 timer_list
-rw-r--r--.  1 root      root         0 Jul 31 01:36 timer_stats
dr-xr-xr-x.  4 root      root         0 Jul 31 01:36 tty
-r--r--r--.  1 root      root         0 Jul 31 01:36 uptime
-r--r--r--.  1 root      root         0 Jul 31 01:36 version
-r--------.  1 root      root         0 Jul 31 01:36 vmallocinfo
-r--r--r--.  1 root      root         0 Jul 28 20:32 vmstat
-r--r--r--.  1 root      root         0 Jul 31 01:36 zoneinfo

值得注意的是,使用"sysctl -a | more"指令,我們可以直接獲得當前/proc中儲存的所有變數,一次性全部顯示出來

文章接下來的部分,我們按照邏輯功能對它們進行分類,逐類學習

Relevant Link:

http://www.ibm.com/developerworks/cn/linux/l-proc.html
http://www.comptechdoc.org/os/linux/howlinuxworks/linux_hlproc.html
http://wenku.baidu.com/view/056b1ad780eb6294dd886c78.html

 

2. 核心機制相關

0x1: /proc/interrupts: The number of interrupts per IRQ

           CPU0       
  0:        606   IO-APIC-edge      timer
  1:      13433   IO-APIC-edge      i8042
  3:          3   IO-APIC-edge    
  4:      53832   IO-APIC-edge    
  7:          0   IO-APIC-edge      parport0
  8:          1   IO-APIC-edge      rtc0
  9:          0   IO-APIC-fasteoi   acpi
 12:      25137   IO-APIC-edge      i8042
 14:          0   IO-APIC-edge      ata_piix
 15:          0   IO-APIC-edge      ata_piix
 16:      29335   IO-APIC-fasteoi   Ensoniq AudioPCI
 17:     125483   IO-APIC-fasteoi   ehci_hcd:usb1, ioc0
 18:        672   IO-APIC-fasteoi   uhci_hcd:usb2
 19:     542116   IO-APIC-fasteoi   eth0
 24:          0   PCI-MSI-edge      pciehp
 25:          0   PCI-MSI-edge      pciehp
 26:          0   PCI-MSI-edge      pciehp
 27:          0   PCI-MSI-edge      pciehp
 28:          0   PCI-MSI-edge      pciehp
 29:          0   PCI-MSI-edge      pciehp
 30:          0   PCI-MSI-edge      pciehp
 31:          0   PCI-MSI-edge      pciehp
 32:          0   PCI-MSI-edge      pciehp
 33:          0   PCI-MSI-edge      pciehp
 34:          0   PCI-MSI-edge      pciehp
 35:          0   PCI-MSI-edge      pciehp
 36:          0   PCI-MSI-edge      pciehp
 37:          0   PCI-MSI-edge      pciehp
 38:          0   PCI-MSI-edge      pciehp
 39:          0   PCI-MSI-edge      pciehp
 40:          0   PCI-MSI-edge      pciehp
 41:          0   PCI-MSI-edge      pciehp
 42:          0   PCI-MSI-edge      pciehp
 43:          0   PCI-MSI-edge      pciehp
 44:          0   PCI-MSI-edge      pciehp
 45:          0   PCI-MSI-edge      pciehp
 46:          0   PCI-MSI-edge      pciehp
 47:          0   PCI-MSI-edge      pciehp
 48:          0   PCI-MSI-edge      pciehp
 49:          0   PCI-MSI-edge      pciehp
 50:          0   PCI-MSI-edge      pciehp
 51:          0   PCI-MSI-edge      pciehp
 52:          0   PCI-MSI-edge      pciehp
 53:          0   PCI-MSI-edge      pciehp
 54:          0   PCI-MSI-edge      pciehp
 55:          0   PCI-MSI-edge      pciehp
 56:     815644   PCI-MSI-edge      ahci
NMI:          0   Non-maskable interrupts
LOC:    4947286   Local timer interrupts
SPU:          0   Spurious interrupts
PMI:          0   Performance monitoring interrupts
IWI:          0   IRQ work interrupts
RES:          0   Rescheduling interrupts
CAL:          0   Function call interrupts
TLB:          0   TLB shootdowns
TRM:          0   Thermal event interrupts
THR:          0   Threshold APIC interrupts
MCE:          0   Machine check exceptions
MCP:        391   Machine check polls
ERR:          0
MIS:          0

0x2: /proc/ioports: A list of currently registered input-output port regions that are in use

列出當前系統所有的輸入輸出介面

0000-0cf7 : PCI Bus 0000:00
  0000-001f : dma1
  0020-0021 : pic1
  0040-0043 : timer0
  0050-0053 : timer1
  0060-0060 : keyboard
  0064-0064 : keyboard
  0070-0071 : rtc0
  0080-008f : dma page reg
  00a0-00a1 : pic2
  00c0-00df : dma2
  00f0-00ff : fpu
  0170-0177 : 0000:00:07.1
    0170-0177 : ata_piix
  01f0-01f7 : 0000:00:07.1
    01f0-01f7 : ata_piix
  02f8-02ff : serial
  0376-0376 : 0000:00:07.1
    0376-0376 : ata_piix
  0378-037a : parport0
  03c0-03df : vga+
  03f6-03f6 : 0000:00:07.1
    03f6-03f6 : ata_piix
  03f8-03ff : serial
  0cf0-0cf1 : pnp 00:01

0cf8-0cff : PCI conf1

0d00-feff : PCI Bus 0000:00
  1000-103f : 0000:00:07.3
    1000-103f : pnp 00:01
      1000-1003 : ACPI PM1a_EVT_BLK
      1004-1005 : ACPI PM1a_CNT_BLK
      1008-100b : ACPI PM_TMR
      100c-100f : ACPI GPE0_BLK
      1010-1015 : ACPI CPU throttle
  1040-104f : 0000:00:07.3
    1040-104f : pnp 00:01
  1060-106f : 0000:00:07.1
    1060-106f : ata_piix
  1070-107f : 0000:00:0f.0
  1080-10bf : 0000:00:07.7
  1400-14ff : 0000:00:10.0
  2000-3fff : PCI Bus 0000:02
    2000-207f : 0000:02:01.0
      2000-201f : pcnet32_probe_pci
    2080-20bf : 0000:02:02.0
      2080-20bf : Ensoniq AudioPCI
    20c0-20df : 0000:02:00.0
      20c0-20df : uhci_hcd
  4000-4fff : PCI Bus 0000:03
  5000-5fff : PCI Bus 0000:0b
  6000-6fff : PCI Bus 0000:13
  7000-7fff : PCI Bus 0000:1b
  8000-8fff : PCI Bus 0000:04
  9000-9fff : PCI Bus 0000:0c
  a000-afff : PCI Bus 0000:14
  b000-bfff : PCI Bus 0000:1c
  c000-cfff : PCI Bus 0000:05
  d000-dfff : PCI Bus 0000:0d
  e000-efff : PCI Bus 0000:15
  fce0-fcff : pnp 00:0d

0x3: /proc/locks

cat /proc/locks 
1: FLOCK  ADVISORY  WRITE 8089 08:03:694 0 EOF
2: POSIX  ADVISORY  WRITE 8072 08:03:20385 0 EOF
3: FLOCK  ADVISORY  WRITE 8057 08:03:2498 0 EOF
4: POSIX  ADVISORY  WRITE 8040 08:03:2070 0 EOF
5: FLOCK  ADVISORY  WRITE 8016 08:03:19948 0 EOF
6: FLOCK  ADVISORY  WRITE 8016 08:03:335 0 EOF
7: FLOCK  ADVISORY  WRITE 1344 08:03:123 0 EOF

0x4: /proc/modules: A list of kernel modules loaded by the system

tcp_diag 693 0 - Live 0xf7e3e000
inet_diag 7334 1 tcp_diag, Live 0xf7e2c000
lp 6830 0 - Live 0xf7ef4000
rfcomm 61472 4 - Live 0xf8007000
sco 14781 2 - Live 0xf7edb000
bridge 67439 0 - Live 0xf7f5d000
bnep 13428 2 - Live 0xf7ed0000
l2cap 47378 16 rfcomm,bnep, Live 0xf7eac000
8021q 20355 0 - Live 0xf7e6c000
garp 5703 1 8021q, Live 0xf7e41000
stp 1626 2 bridge,garp, Live 0xf7e38000
llc 4258 3 bridge,garp,stp, Live 0xf7e30000
ipt_REJECT 1867 2 - Live 0xf8c98000
nf_conntrack_ipv4 7694 2 - Live 0xf8c8f000
nf_defrag_ipv4 1039 1 nf_conntrack_ipv4, Live 0xf8c85000
iptable_filter 2173 1 - Live 0xf8c7d000
ip_tables 9567 1 iptable_filter, Live 0xf8c74000
ip6t_REJECT 3987 2 - Live 0xf8c66000
nf_conntrack_ipv6 6940 2 - Live 0xf8c5d000
nf_defrag_ipv6 8839 1 nf_conntrack_ipv6, Live 0xf8c52000
xt_state 1064 4 - Live 0xf8c48000
nf_conntrack 65661 3 nf_conntrack_ipv4,nf_conntrack_ipv6,xt_state, Live 0xf8c2b000
ip6table_filter 2245 1 - Live 0xf8c0c000
ip6_tables 10301 1 ip6table_filter, Live 0xf8c03000
ipv6 261676 27 ip6t_REJECT,nf_conntrack_ipv6,nf_defrag_ipv6, Live 0xf8bad000
fuse 62472 4 - Live 0xf8b3b000
uinput 6020 0 - Live 0xf8a16000
microcode 12248 0 - Live 0xf8a04000
ppdev 7297 0 - Live 0xf89f6000
vmware_balloon 5811 0 - Live 0xf89ec000
snd_ens1371 16851 4 - Live 0xf89de000
snd_rawmidi 18061 1 snd_ens1371, Live 0xf89cb000
snd_ac97_codec 95611 1 snd_ens1371, Live 0xf89a2000
ac97_bus 968 1 snd_ac97_codec, Live 0xf897d000
snd_seq 44677 0 - Live 0xf896a000
snd_seq_device 5124 2 snd_rawmidi,snd_seq, Live 0xf8953000
snd_pcm 68374 3 snd_ens1371,snd_ac97_codec, Live 0xf8935000
snd_timer 17216 3 snd_seq,snd_pcm, Live 0xf8913000
snd 52350 13 snd_ens1371,snd_rawmidi,snd_ac97_codec,snd_seq,snd_seq_device,snd_pcm,snd_timer, Live 0xf88f5000
soundcore 6390 1 snd, Live 0xf88da000
snd_page_alloc 7236 1 snd_pcm, Live 0xf88cf000
pcnet32 29234 0 - Live 0xf88be000
mii 4476 1 pcnet32, Live 0xf88ac000
parport_pc 19086 1 - Live 0xf889f000
parport 29925 3 lp,ppdev,parport_pc, Live 0xf8887000
btusb 14139 2 - Live 0xf8872000
bluetooth 83558 9 rfcomm,sco,bnep,l2cap,btusb, Live 0xf884c000
rfkill 14794 3 bluetooth, Live 0xf8823000
sg 24038 0 - Live 0xf8810000
i2c_piix4 11156 0 - Live 0xf87fe000
i2c_core 25632 1 i2c_piix4, Live 0xf87eb000
ext4 335766 2 - Live 0xf807c000
jbd2 76054 1 ext4, Live 0xf7ff3000
mbcache 6017 1 ext4, Live 0xf7fd1000
sr_mod 13282 0 - Live 0xf7fc5000
cdrom 33416 1 sr_mod, Live 0xf7fb1000
sd_mod 34952 4 - Live 0xf7f97000
crc_t10dif 1217 1 sd_mod, Live 0xf7f84000
ahci 35561 0 - Live 0xf7f72000
pata_acpi 2513 0 - Live 0xf7f5b000
ata_generic 2805 0 - Live 0xf7f54000
ata_piix 20861 0 - Live 0xf7f2c000
mptspi 14567 3 - Live 0xf7ef7000
mptscsih 31362 1 mptspi, Live 0xf7ee2000
mptbase 86744 2 mptspi,mptscsih, Live 0xf7eb9000
scsi_transport_spi 20014 1 mptspi, Live 0xf7e93000
dm_mirror 11969 0 - Live 0xf7e83000
dm_region_hash 9644 1 dm_mirror, Live 0xf7e74000
dm_log 8322 2 dm_mirror,dm_region_hash, Live 0xf7e68000
dm_mod 70099 2 dm_mirror,dm_log, Live 0xf7e48000

lsmod指令就是通過這個虛擬裝置(整個/proc就是一個溝通user mode和kernel mode的虛擬裝置)獲取到的

0x5: /proc/net: Various network pseudo files. The netstat command suite provides cleaner access to these files
net指令就是通過讀者/proc/net目錄下的檔案得到的網路連線資訊的

1. arp: The kernel address resolution protocol table
2. dev: Network device status information
3. ipx
4. ipx_route
5. rarp: used to provide rarp services
6. raw: A dump of the RAW socket table
7. route: Looks like route
8. snmp: Holds the ASCII databases used for the IP, ICMP, TCP, and UDP management information bases for an snmp agent.
9. tcp: A dump of the TCP socket table.
10. udp: A dump of the UDP socket table
11. unix: Lists UNIX domain sockets and their status

12. packet 
顯示了當前正在處理網路資料包的程式
http://blog.cloudpassage.com/2012/09/05/warn-packet-sniffer-running/
http://www.onlamp.com/pub/a/linux/2000/11/16/LinuxAdmin.html

這個目錄下還有很多檔案,但是作用不大,就沒有列出來,有興趣的朋友可以使用: ll /proc/net/進行檢視

0x6: /proc/slabinfo

slabinfo - version: 2.1
# name            <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab> : tunables <limit> <batchcount> <sharedfactor> : slabdata <active_slabs> <num_slabs> <sharedavail>
bridge_fdb_cache       0      0     32  113    1 : tunables  120   60    0 : slabdata      0      0      0
nf_conntrack_expect      0      0    168   23    1 : tunables  120   60    0 : slabdata      0      0      0
nf_conntrack_c0acb540      1     16    240   16    1 : tunables  120   60    0 : slabdata      1      1      0
fib6_nodes            22    113     32  113    1 : tunables  120   60    0 : slabdata      1      1      0
ip6_dst_cache         13     30    256   15    1 : tunables  120   60    0 : slabdata      2      2      0
ndisc_cache            1     20    192   20    1 : tunables  120   60    0 : slabdata      1      1      0
ip6_mrt_cache          0      0    128   30    1 : tunables  120   60    0 : slabdata      0      0      0
RAWv6                  4      5    768    5    1 : tunables   54   27    0 : slabdata      1      1      0
UDPLITEv6              0      0    704   11    2 : tunables   54   27    0 : slabdata      0      0      0
UDPv6                  0      0    704   11    2 : tunables   54   27    0 : slabdata      0      0      0
tw_sock_TCPv6          0      0    256   15    1 : tunables  120   60    0 : slabdata      0      0      0
request_sock_TCPv6      0      0    128   30    1 : tunables  120   60    0 : slabdata      0      0      0
TCPv6                  3      5   1408    5    2 : tunables   24   12    0 : slabdata      1      1      0
fuse_request           4     13    296   13    1 : tunables   54   27    0 : slabdata      1      1      0
fuse_inode             3      9    448    9    1 : tunables   54   27    0 : slabdata      1      1      0
jbd2_1k                0      0   1024    4    1 : tunables   54   27    0 : slabdata      0      0      0
avtab_node        551052 551145     16  203    1 : tunables  120   60    0 : slabdata   2715   2715      0
ext4_inode_cache   77697  78576    644    6    1 : tunables   54   27    0 : slabdata  13096  13096      0
ext4_xattr            11     78     48   78    1 : tunables  120   60    0 : slabdata      1      1      0
ext4_free_block_extents      0      0     36  101    1 : tunables  120   60    0 : slabdata      0      0      0
ext4_alloc_context      0      0    108   36    1 : tunables  120   60    0 : slabdata      0      0      0
ext4_prealloc_space      3     56     68   56    1 : tunables  120   60    0 : slabdata      1      1      0
ext4_system_zone       0      0     24  145    1 : tunables  120   60    0 : slabdata      0      0      0
jbd2_journal_handle      0      0     20  169    1 : tunables  120   60    0 : slabdata      0      0      0
jbd2_journal_head      8    315     60   63    1 : tunables  120   60    0 : slabdata      5      5      0
jbd2_revoke_table      4    254     12  254    1 : tunables  120   60    0 : slabdata      1      1      0
jbd2_revoke_record      0      0     32  113    1 : tunables  120   60    0 : slabdata      0      0      0
sd_ext_cdb             2    113     32  113    1 : tunables  120   60    0 : slabdata      1      1      0
scsi_sense_cache      90     90    128   30    1 : tunables  120   60    0 : slabdata      3      3      0
scsi_cmd_cache        80     80    192   20    1 : tunables  120   60    0 : slabdata      4      4      0
dm_raid1_read_record      0      0   1052    7    2 : tunables   24   12    0 : slabdata      0      0      0
kcopyd_job             0      0   2340    3    2 : tunables   24   12    0 : slabdata      0      0      0
io                     0      0     32  113    1 : tunables  120   60    0 : slabdata      0      0      0
dm_uevent              0      0   2460    3    2 : tunables   24   12    0 : slabdata      0      0      0
dm_rq_clone_bio_info      0      0      8  339    1 : tunables  120   60    0 : slabdata      0      0      0
dm_rq_target_io        0      0    248   16    1 : tunables  120   60    0 : slabdata      0      0      0
dm_target_io           0      0     16  203    1 : tunables  120   60    0 : slabdata      0      0      0
dm_io                  0      0     24  145    1 : tunables  120   60    0 : slabdata      0      0      0
flow_cache             0      0     84   46    1 : tunables  120   60    0 : slabdata      0      0      0
uhci_urb_priv          5    127     28  127    1 : tunables  120   60    0 : slabdata      1      1      0
cfq_io_context        75    112     68   56    1 : tunables  120   60    0 : slabdata      2      2      0
cfq_queue             75     78    152   26    1 : tunables  120   60    0 : slabdata      3      3      0
bsg_cmd                0      0    284   14    1 : tunables   54   27    0 : slabdata      0      0      0
mqueue_inode_cache      1      7    576    7    1 : tunables   54   27    0 : slabdata      1      1      0
isofs_inode_cache      0      0    380   10    1 : tunables   54   27    0 : slabdata      0      0      0
hugetlbfs_inode_cache      1     11    352   11    1 : tunables   54   27    0 : slabdata      1      1      0
dquot                  0      0    192   20    1 : tunables  120   60    0 : slabdata      0      0      0
kioctx                 0      0    256   15    1 : tunables  120   60    0 : slabdata      0      0      0
kiocb                  0      0    192   20    1 : tunables  120   60    0 : slabdata      0      0      0
inotify_event_private_data      2    203     16  203    1 : tunables  120   60    0 : slabdata      1      1      0
inotify_inode_mark_entry    234    252     60   63    1 : tunables  120   60    0 : slabdata      4      4      0
dnotify_mark_entry      0      0     60   63    1 : tunables  120   60    0 : slabdata      0      0      0
dnotify_struct         0      0     20  169    1 : tunables  120   60    0 : slabdata      0      0      0
dio                    0      0    320   12    1 : tunables   54   27    0 : slabdata      0      0      0
fasync_cache           5    203     16  203    1 : tunables  120   60    0 : slabdata      1      1      0
ksm_mm_slot            0      0     24  145    1 : tunables  120   60    0 : slabdata      0      0      0
ksm_stable_node        0      0     20  169    1 : tunables  120   60    0 : slabdata      0      0      0
ksm_rmap_item          0      0     32  113    1 : tunables  120   60    0 : slabdata      0      0      0
utrace_engine          0      0     28  127    1 : tunables  120   60    0 : slabdata      0      0      0
utrace                 0      0     32  113    1 : tunables  120   60    0 : slabdata      0      0      0
pid_namespace          0      0     76   50    1 : tunables  120   60    0 : slabdata      0      0      0
posix_timers_cache      0      0    120   32    1 : tunables  120   60    0 : slabdata      0      0      0
uid_cache              5     59     64   59    1 : tunables  120   60    0 : slabdata      1      1      0
UNIX                 592    609    512    7    1 : tunables   54   27    0 : slabdata     87     87      0
ip_mrt_cache           0      0    128   30    1 : tunables  120   60    0 : slabdata      0      0      0
UDP-Lite               0      0    640    6    1 : tunables   54   27    0 : slabdata      0      0      0
tcp_bind_bucket        4    113     32  113    1 : tunables  120   60    0 : slabdata      1      1      0
inet_peer_cache        2     59     64   59    1 : tunables  120   60    0 : slabdata      1      1      0
secpath_cache          0      0     32  113    1 : tunables  120   60    0 : slabdata      0      0      0
xfrm_dst_cache         0      0    320   12    1 : tunables   54   27    0 : slabdata      0      0      0
ip_fib_alias           0      0     16  203    1 : tunables  120   60    0 : slabdata      0      0      0
ip_fib_hash           10    101     36  101    1 : tunables  120   60    0 : slabdata      1      1      0
ip_dst_cache          21     30    256   15    1 : tunables  120   60    0 : slabdata      2      2      0
arp_cache              4     20    192   20    1 : tunables  120   60    0 : slabdata      1      1      0
PING                   0      0    576    7    1 : tunables   54   27    0 : slabdata      0      0      0
RAW                    2      7    576    7    1 : tunables   54   27    0 : slabdata      1      1      0
UDP                    2      6    640    6    1 : tunables   54   27    0 : slabdata      1      1      0
tw_sock_TCP            0      0    192   20    1 : tunables  120   60    0 : slabdata      0      0      0
request_sock_TCP       0      0    128   30    1 : tunables  120   60    0 : slabdata      0      0      0
TCP                    5      6   1280    3    1 : tunables   24   12    0 : slabdata      2      2      0
eventpoll_pwq         59    101     36  101    1 : tunables  120   60    0 : slabdata      1      1      0
eventpoll_epi         59     90    128   30    1 : tunables  120   60    0 : slabdata      3      3      0
sgpool-128             2      2   3072    2    2 : tunables   24   12    0 : slabdata      1      1      0
sgpool-64              2      5   1536    5    2 : tunables   24   12    0 : slabdata      1      1      0
sgpool-32              2      5    768    5    1 : tunables   54   27    0 : slabdata      1      1      0
sgpool-16              2     10    384   10    1 : tunables   54   27    0 : slabdata      1      1      0
sgpool-8               4     20    192   20    1 : tunables  120   60    0 : slabdata      1      1      0
scsi_data_buffer       0      0     20  169    1 : tunables  120   60    0 : slabdata      0      0      0
blkdev_integrity       0      0     64   59    1 : tunables  120   60    0 : slabdata      0      0      0
blkdev_queue          27     28   1744    4    2 : tunables   24   12    0 : slabdata      7      7      0
blkdev_requests       68     68    224   17    1 : tunables  120   60    0 : slabdata      4      4      0
blkdev_ioc            72    144     52   72    1 : tunables  120   60    0 : slabdata      2      2      0
fsnotify_event_holder      0      0     12  254    1 : tunables  120   60    0 : slabdata      0      0      0
fsnotify_event         2     63     60   63    1 : tunables  120   60    0 : slabdata      1      1      0
bio-0                  4     30    128   30    1 : tunables  120   60    0 : slabdata      1      1      0
biovec-256             2      2   3072    2    2 : tunables   24   12    0 : slabdata      1      1      0
biovec-128             0      0   1536    5    2 : tunables   24   12    0 : slabdata      0      0      0
biovec-64              0      0    768    5    1 : tunables   54   27    0 : slabdata      0      0      0
biovec-16              0      0    192   20    1 : tunables  120   60    0 : slabdata      0      0      0
bip-256                2      2   3136    2    2 : tunables   24   12    0 : slabdata      1      1      0
bip-128                0      0   1600    5    2 : tunables   24   12    0 : slabdata      0      0      0
bip-64                 0      0    832    9    2 : tunables   54   27    0 : slabdata      0      0      0
bip-16                 0      0    256   15    1 : tunables  120   60    0 : slabdata      0      0      0
bip-4                  0      0    128   30    1 : tunables  120   60    0 : slabdata      0      0      0
bip-1                  0      0     64   59    1 : tunables  120   60    0 : slabdata      0      0      0
sock_inode_cache     679    684    448    9    1 : tunables   54   27    0 : slabdata     76     76      0
skbuff_fclone_cache      0      0    384   10    1 : tunables   54   27    0 : slabdata      0      0      0
skbuff_head_cache    111    120    192   20    1 : tunables  120   60    0 : slabdata      6      6      0
file_lock_cache        7     39    100   39    1 : tunables  120   60    0 : slabdata      1      1      0
net_namespace          0      0   1376    5    2 : tunables   24   12    0 : slabdata      0      0      0
shmem_inode_cache    726    729    448    9    1 : tunables   54   27    0 : slabdata     81     81      0
Acpi-Operand        4288   4416     40   92    1 : tunables  120   60    0 : slabdata     48     48      0
Acpi-ParseExt          0      0     48   78    1 : tunables  120   60    0 : slabdata      0      0      0
Acpi-Parse             0      0     32  113    1 : tunables  120   60    0 : slabdata      0      0      0
Acpi-State             0      0     44   84    1 : tunables  120   60    0 : slabdata      0      0      0
Acpi-Namespace      3218   3335     24  145    1 : tunables  120   60    0 : slabdata     23     23      0
task_delay_info      279    300     76   50    1 : tunables  120   60    0 : slabdata      6      6      0
taskstats              7     12    328   12    1 : tunables   54   27    0 : slabdata      1      1      0
proc_inode_cache    4663   4790    384   10    1 : tunables   54   27    0 : slabdata    479    479      0
sigqueue               8     27    144   27    1 : tunables  120   60    0 : slabdata      1      1      0
bdev_cache            31     35    512    7    1 : tunables   54   27    0 : slabdata      5      5      0
sysfs_dir_cache    12048  12050     76   50    1 : tunables  120   60    0 : slabdata    241    241      0
mnt_cache             29     40    192   20    1 : tunables  120   60    0 : slabdata      2      2      0
filp                4890   5010    128   30    1 : tunables  120   60    0 : slabdata    167    167      0
inode_cache        10624  10626    352   11    1 : tunables   54   27    0 : slabdata    966    966      0
dentry            103609 105386    132   29    1 : tunables  120   60    0 : slabdata   3634   3634      0
names_cache            6      6   4096    1    1 : tunables   24   12    0 : slabdata      6      6      0
avc_node             512    624     48   78    1 : tunables  120   60    0 : slabdata      8      8      0
selinux_inode_security  94408  96012     44   84    1 : tunables  120   60    0 : slabdata   1143   1143      0
radix_tree_node    22287  22347    296   13    1 : tunables   54   27    0 : slabdata   1719   1719      0
key_jar                3     30    128   30    1 : tunables  120   60    0 : slabdata      1      1      0
buffer_head        27980  30485     56   67    1 : tunables  120   60    0 : slabdata    455    455      0
nsproxy                0      0     24  145    1 : tunables  120   60    0 : slabdata      0      0      0
vm_area_struct      9472  10218    100   39    1 : tunables  120   60    0 : slabdata    262    262      0
mm_struct             99     99    448    9    1 : tunables   54   27    0 : slabdata     11     11      0
fs_cache             104    113     32  113    1 : tunables  120   60    0 : slabdata      1      1      0
files_cache          105    105    256   15    1 : tunables  120   60    0 : slabdata      7      7      0
signal_cache         180    180    640    6    1 : tunables   54   27    0 : slabdata     30     30      0
sighand_cache        177    177   1344    3    1 : tunables   24   12    0 : slabdata     59     59      0
task_xstate          279    279    832    9    2 : tunables   54   27    0 : slabdata     31     31      0
task_struct          274    276   1360    3    1 : tunables   24   12    0 : slabdata     92     92      0
cred_jar             423    510    128   30    1 : tunables  120   60    0 : slabdata     17     17      0
anon_vma_chain      6501   7540     24  145    1 : tunables  120   60    0 : slabdata     52     52      0
anon_vma            5053   5577     20  169    1 : tunables  120   60    0 : slabdata     33     33      0
pid                  295    295     64   59    1 : tunables  120   60    0 : slabdata      5      5      0
idr_layer_cache      626    650    148   26    1 : tunables  120   60    0 : slabdata     25     25      0
size-4194304(DMA)      0      0 4194304    1 1024 : tunables    1    1    0 : slabdata      0      0      0
size-4194304           0      0 4194304    1 1024 : tunables    1    1    0 : slabdata      0      0      0
size-2097152(DMA)      0      0 2097152    1  512 : tunables    1    1    0 : slabdata      0      0      0
size-2097152           0      0 2097152    1  512 : tunables    1    1    0 : slabdata      0      0      0
size-1048576(DMA)      0      0 1048576    1  256 : tunables    1    1    0 : slabdata      0      0      0
size-1048576           0      0 1048576    1  256 : tunables    1    1    0 : slabdata      0      0      0
size-524288(DMA)       0      0 524288    1  128 : tunables    1    1    0 : slabdata      0      0      0
size-524288            0      0 524288    1  128 : tunables    1    1    0 : slabdata      0      0      0
size-262144(DMA)       0      0 262144    1   64 : tunables    1    1    0 : slabdata      0      0      0
size-262144            0      0 262144    1   64 : tunables    1    1    0 : slabdata      0      0      0
size-131072(DMA)       0      0 131072    1   32 : tunables    8    4    0 : slabdata      0      0      0
size-131072            0      0 131072    1   32 : tunables    8    4    0 : slabdata      0      0      0
size-65536(DMA)        0      0  65536    1   16 : tunables    8    4    0 : slabdata      0      0      0
size-65536             2      2  65536    1   16 : tunables    8    4    0 : slabdata      2      2      0
size-32768(DMA)        0      0  32768    1    8 : tunables    8    4    0 : slabdata      0      0      0
size-32768             0      0  32768    1    8 : tunables    8    4    0 : slabdata      0      0      0
size-16384(DMA)        0      0  16384    1    4 : tunables    8    4    0 : slabdata      0      0      0
size-16384            37     37  16384    1    4 : tunables    8    4    0 : slabdata     37     37      0
size-8192(DMA)         0      0   8192    1    2 : tunables    8    4    0 : slabdata      0      0      0
size-8192              9      9   8192    1    2 : tunables    8    4    0 : slabdata      9      9      0
size-4096(DMA)         0      0   4096    1    1 : tunables   24   12    0 : slabdata      0      0      0
size-4096             59     59   4096    1    1 : tunables   24   12    0 : slabdata     59     59      0
size-2048(DMA)         0      0   2048    2    1 : tunables   24   12    0 : slabdata      0      0      0
size-2048            150    150   2048    2    1 : tunables   24   12    0 : slabdata     75     75      0
size-1024(DMA)         0      0   1024    4    1 : tunables   54   27    0 : slabdata      0      0      0
size-1024            516    516   1024    4    1 : tunables   54   27    0 : slabdata    129    129      0
size-512(DMA)          0      0    512    8    1 : tunables   54   27    0 : slabdata      0      0      0
size-512             842    856    512    8    1 : tunables   54   27    0 : slabdata    107    107      0
size-256(DMA)          0      0    256   15    1 : tunables  120   60    0 : slabdata      0      0      0
size-256             144    150    256   15    1 : tunables  120   60    0 : slabdata     10     10      0
size-192(DMA)          0      0    192   20    1 : tunables  120   60    0 : slabdata      0      0      0
size-192             960    960    192   20    1 : tunables  120   60    0 : slabdata     48     48      0
size-128(DMA)          0      0    128   30    1 : tunables  120   60    0 : slabdata      0      0      0
size-128             776    780    128   30    1 : tunables  120   60    0 : slabdata     26     26      0
size-96(DMA)           0      0    128   30    1 : tunables  120   60    0 : slabdata      0      0      0
size-96             1470   1470    128   30    1 : tunables  120   60    0 : slabdata     49     49      0
size-64(DMA)           0      0     64   59    1 : tunables  120   60    0 : slabdata      0      0      0
size-32(DMA)           0      0     32  113    1 : tunables  120   60    0 : slabdata      0      0      0
size-64             5007   5133     64   59    1 : tunables  120   60    0 : slabdata     87     87      0
size-32           368885 369058     32  113    1 : tunables  120   60    0 : slabdata   3266   3266      0
kmem_cache           186    195    256   15    1 : tunables  120   60    0 : slabdata     13     13      0

0x7: /proc/sys: Directory corresponding to kernel variables

1. debug
2. dev
3. fs
4. kernel
    4.1 domainname
    4.2 file-max
    4.3 file-nr
    4.4 hostname
    4.5 inode-max
    4.6 inode-nr
    4.7 osrelease
    4.8 ostype
    4.9 panic
    4.10 real-root-dev
    4.11 securelevel
    4.12 version
5. net
6. proc
7. sunrpc
8. vm

0x8: /proc/kallsyms

在v2.6.0的核心中,為了更好地除錯核心,引入新的功能kallsyms(前提是編譯核心的時候開啟了: static int all_symbols = 1;)
kallsyms把核心用到的所有函式地址和名稱連線進核心檔案,當核心啟動後,同時載入到記憶體中

1. 當發生oops,例如在核心中訪問空地址時,核心就會解析eip位於哪個函式中,並列印出形如:
EIP is at cleanup_module+0xb/0x1d [client]的資訊,
2. 呼叫棧也用可讀的方式顯示出來.
Call Trace:
[<c013096d>] sys_delete_module+0x191/0x1ce
[<c02dd30a>] do_page_fault+0x189/0x51d
[<c0102bc1>] syscall_call+0x7/0xb
3. 還可以查詢某個函式例如的sys_fork的地址,然後hook它,kprobe就是這麼幹的

在v2.6.20 中,還可以包含所有符號的地址,應此功能更強大,就相當於核心中有了System.map了,這時候就可以很方便的查詢sys_call_table的地址了

echo 0 > /proc/sys/kernel/kptr_restrict sysctl
cat /proc/kallsyms 
//輸出全部核心匯出的、未匯出的符號表

Relevant Link:

http://blog.sina.com.cn/s/blog_86b97e1601010z3b.html
http://blog.chinaunix.net/uid-27717694-id-3985448.html 

 

3. 程式資訊

0x1: 以程式PID為目錄名的目錄

當前linux執行中的每一個程式在/proc下一定都可以找到一個對應的以它的程式號作為目錄名的子目錄,這個目錄描述這個程式的相關資訊。
每個程式對應的目錄都包含了如下的子目錄

1. cmdline: The command line the process was invoked with
啟動當前程式的命令列,即使用者使用什麼指令來啟動這個程式,例如: /usr/bin/shell arg1 arg2,則這個shell程式的cmdline就是"/usr/bin/shell arg1 arg2"

2. cwd: A link to the current working directory of the process
指向當前程式的"工作目錄"的符號連結

3. environ: The process environment
當前程式的環境變數

4. exe: A pointer appearing as a symbolic link to the binary that was executed
這個程式對應於磁碟上的程式檔名稱,包括完整路徑,例如"/usr/bin/shell"

5. fd: A subdirectory with one entry per file that the process has open
    1) 0-std input
    2) 1-std output
    3) 2-std err
6. maps: Contains the currently mapped memory regions and their access permissions. The format is:
address            perms    offset        dev    idnode    filename
08048000-0804e000    r-xp    00000400    0302    192233    /sbin/init
0804e000-0804f000    rw-p    00005000    0302    192233    /sbin/init 

7. mem: The memory of the process that accesses the /dev/mem device

8. root: Points to the root filesystem
指向根目錄"/"的符號連結

9. stat: Status information about the process used by the ps command 
    1) pid: Process id(程式pdi)
    2) comm: The executable filename(可執行檔名)
    3) state:
        3.1) R(running)
        3.2) S(sleeping interruptable)
        3.3) D(sleeping)
        3.4) Z(zombie)
        3.5) T(stopped on a signal)    
    4) ppid: Parent process ID(父程式pid)
    5) pgrp: Process group ID(程式所屬組)
    6) session: The process session ID(程式session會話id)
    7) tty: The tty the process is using(程式所使用的tty)
    8) tpgid: The process group ID of the owning process of the tty the current process is connected to.
    9) flags: Process flags
    10) minflt: Minor faults the process has made
    11) cminflt: Minor faults the process and its children have made.
    12) majflt
    13) cmajflt
    14) utime: The number of jiffies (processor time) that this process has been scheduled in user mode
    當前程式在"使用者態"所消耗的CPU排程時間
    15) stime: in kernel mode
    當前程式在"核心態"所消耗的CPU排程時間
    16) cutime: This process and its children in user mode
    當前程式以及子程式在"使用者態"所消耗的CPU時間
    17) cstime: in kernel mode
    當前程式以及子程式在"核心態"所消耗的CPU時間
    18) counter: The maximum time of this processes next time slice
    這個欄位和CPU排程相關,counter表明它的所剩的時間片,即動態優先順序(時間片越少自然優先順序就越低了)
    19) priority: The priority of the nice(process priority) value plus fifteen
    20) timeout: The time in jiffies of the process's next timeout.
    21) itrealvalue: The time in jiffies before the next SIGALRM is sent to the process because of an internal timer.
    22) starttime: Time the process started after system boot
    當前程式已執行時間
    23) vsize: Virtual memory size
    當前程式所佔用的虛擬記憶體
    24) rlim: Current limit in bytes of the rss of the process.
    25) startcode: The address above which program text can run.
    26) endcode: The address below which program text can run.
    27) startstack: The address of the start of the stack
    28) kstkesp: The current value of esp for the process as found in the kernel stack page.
    29) kstkeip: The current 32 bit instruction pointer, EIP.
    30) signal: The bitmap of pending signals
    31) blocked: The bitmap of blocked signals
    32) sigignore: The bitmap of ignored signals
    33) sigcatch: The bitmap of catched signals
    34) wchan: The channel in which the process is waiting. The "ps -l" command gives somewhat of a list.

0x2: /proc/[pid]/maps

這個檔案用於檢視程式的虛擬地址空間是如何使用的,檔案有6列,分別為:

1. 地址:庫在程式裡地址範圍
2. 許可權:虛擬記憶體的許可權
    1) r =2) w =3) x = 執行
    4) s = 共享
    5) p = 私有
3. 偏移量:庫在程式裡地址範圍
4. 裝置:映像檔案的主裝置號和次裝置號 
5. 節點:映像檔案的節點號
6. 路徑: 映像檔案的路徑

每項都與一個"struct vm_area_struct"結構成員對應

http://www.cnblogs.com/LittleHann/p/3865490.html
搜尋:0x2: vm_area_struct

Relevant Link:

http://blog.sina.com.cn/s/blog_49f07e46010148m0.html

0x3: /proc/[pid]/mem

Linux下使用ptrace呼叫可以監視和控制其他程式,並能夠改變程式的暫存器值和核心映像。ptrace提供了PTRACE_PEEKDATA來實現程式記憶體讀取,這是原語級的操作,在x86_64下一次僅讀取8位元組。因此在讀取量較大時,需要反覆呼叫ptrace。/proc/<PID>/mem介面提供了read呼叫,只需一次就可以讀取任意大小記憶體

Relevant Link:

http://my.oschina.net/u/180497/blog/141673
http://yuangeqingtian.blog.51cto.com/6994701/1214789

 

4. 硬體裝置相關

0x1: /proc/bus

1. pci: A directory
        1.1 00: A directory 
        containing filenames like 00.0, 07.0, 07.1, 07.2, 08.0, 09.0, and 0b.0. Each are 256 bytes long and appear to be in binary form 
        1.2 02: A directory  
        1.3 devices
        I think this file numerically identifies devices on the pci bus. My file contains:
        列舉列出了當前系統掛接的匯流排裝置
    2. input: A directory
    輸入裝置
    3. pccard: A directory
    pccard裝置
    4. usb: A directory
    usb裝置

0x2: /proc/cpuinfo: CPU architecture information

processor    : 0
vendor_id    : GenuineIntel
cpu family    : 6
model        : 69
model name    : Intel(R) Core(TM) i5-4200U CPU @ 1.60GHz
stepping    : 1
cpu MHz        : 2294.740
cache size    : 3072 KB
fdiv_bug    : no
hlt_bug        : no
f00f_bug    : no
coma_bug    : no
fpu        : yes
fpu_exception    : yes
cpuid level    : 13
wp        : yes
flags        : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss nx pdpe1gb rdtscp constant_tsc up arch_perfmon pebs 
bts xtopology tsc_reliable nonstop_tsc aperfmperf unfair_spinlock pni pclmulqdq ssse3 fma pcid sse4_1 sse4_2 x2apic movbe popcnt xsave avx f16c rdrand hypervisor ida arat
epb xsaveopt pln pts dts fsgsbase smep bogomips :
4589.48 clflush size : 64 cache_alignment : 64 address sizes : 40 bits physical, 48 bits virtual power management:

0x3: /proc/devices: Text listing of major numbers and device groups

列出當前系統掛載(mount)的裝置

Character devices:
  1 mem
  4 /dev/vc/0
  4 tty
  4 ttyS
  5 /dev/tty
  5 /dev/console
  5 /dev/ptmx
  6 lp
  7 vcs
 10 misc
 13 input
 14 sound
 21 sg
 29 fb
 99 ppdev
116 alsa
128 ptm
136 pts
162 raw
180 usb
189 usb_device
202 cpu/msr
203 cpu/cpuid
216 rfcomm
249 hidraw
250 usbmon
251 bsg
252 pcmcia
253 watchdog
254 rtc

Block devices:
  1 ramdisk
259 blkext
  7 loop
  8 sd
  9 md
 11 sr
 65 sd
 66 sd
 67 sd
 68 sd
 69 sd
 70 sd
 71 sd
128 sd
129 sd
130 sd
131 sd
132 sd
133 sd
134 sd
135 sd
253 device-mapper
254 mdp

0x4: /proc/dma: A list of ISA direct memory access channels in use

4: cascade

0x5: /proc/fs

1. ext4
2. jbd2
3. nfsd 

0x6: /proc/mounts: Shows mounted filesystems. Shows device, mount point, filesystem type, permissions, and two flags

rootfs / rootfs rw 0 0
proc /proc proc rw,relatime 0 0
sysfs /sys sysfs rw,seclabel,relatime 0 0
devtmpfs /dev devtmpfs rw,seclabel,relatime,size=960940k,nr_inodes=183013,mode=755 0 0
devpts /dev/pts devpts rw,seclabel,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /dev/shm tmpfs rw,seclabel,relatime 0 0
/dev/sda3 / ext4 rw,seclabel,relatime,barrier=1,data=ordered 0 0
none /selinux selinuxfs rw,relatime 0 0
devtmpfs /dev devtmpfs rw,seclabel,relatime,size=960940k,nr_inodes=183013,mode=755 0 0
/proc/bus/usb /proc/bus/usb usbfs rw,relatime 0 0
/dev/sda1 /boot ext4 rw,seclabel,relatime,barrier=1,data=ordered 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw,relatime 0 0
vmware-vmblock /var/run/vmblock-fuse fuse.vmware-vmblock rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other 0 0
gvfs-fuse-daemon /root/.gvfs fuse.gvfs-fuse-daemon rw,nosuid,nodev,relatime,user_id=0,group_id=0 0 0

0x7: /proc/mtrr

reg00: base=0x000000000 (    0MB), size= 2048MB, count=1: write-back

0x8: /proc/scsi: A directory with scsi files and driver directories

1. scsi: A list of all scsi devices known to the kernel
2. device_info - Various scsi driver brand names

dr-xr-xr-x   3 root root 0 Jun  4 17:03 ./
dr-xr-xr-x 117 root root 0 May 21 21:10 ../
-r--r--r--   1 root root 0 Jun  4 17:03 device_info
-r--r--r--   1 root root 0 Jun  4 17:03 scsi
dr-xr-xr-x   2 root root 0 Jun  4 17:03 sg/

0x9: /proc/ioports

root@iZ231vybmaeZ:/usr/local/aegis/aegis_client/aegis_00_73# cat /proc/ioports 
0000-0cf7 : PCI Bus 0000:00
  0000-001f : dma1
  0020-0021 : pic1
  0040-0043 : timer0
  0050-0053 : timer1
  0060-0060 : keyboard
  0064-0064 : keyboard
  0070-0071 : rtc0
  0080-008f : dma page reg
  00a0-00a1 : pic2
  00c0-00df : dma2
  00f0-00ff : fpu
  0170-0177 : 0000:00:01.1
    0170-0177 : ata_piix
  01f0-01f7 : 0000:00:01.1
    01f0-01f7 : ata_piix
  0376-0376 : 0000:00:01.1
    0376-0376 : ata_piix
  03c0-03df : vga+
  03f2-03f2 : floppy
  03f4-03f5 : floppy
  03f6-03f6 : 0000:00:01.1
    03f6-03f6 : ata_piix
  03f7-03f7 : floppy
  04d0-04d1 : pnp 00:02
  08a0-08a3 : pnp 00:02
  0cc0-0ccf : pnp 00:02
0cf8-0cff : PCI conf1
0d00-ffff : PCI Bus 0000:00
  10c0-1141 : pnp 00:01
  1f40-1f7f : 0000:00:01.3
    1f40-1f43 : ACPI PM1a_EVT_BLK
    1f44-1f45 : ACPI PM1a_CNT_BLK
    1f48-1f4b : ACPI PM_TMR
    1f68-1f6f : ACPI GPE0_BLK
  b010-b015 : ACPI CPU throttle
  b044-b047 : pnp 00:01
  c000-c0ff : 0000:00:03.0
    c000-c0ff : xen-platform-pci
  c100-c11f : 0000:00:01.2
    c100-c11f : uhci_hcd
  c120-c12f : 0000:00:01.1
    c120-c12f : ata_piix

 

5. 系統資訊

0x1: /proc/cmdline: 系統命令列

cmdline: The command line at system startup.
My file contains:

"ro root=UUID=c03bcf41-af81-41b2-b476-e986f278bbb2 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=129M@0M  
KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
"

0x2: /proc/filesystems: A text listing of the filesystems compiled into the kernel

顯示當前系統已經安裝支援的檔案系統驅動(即支援哪些檔案系統)

nodev    sysfs
nodev    rootfs
nodev    bdev
nodev    proc
nodev    cgroup
nodev    cpuset
nodev    tmpfs
nodev    devtmpfs
nodev    binfmt_misc
nodev    debugfs
nodev    securityfs
nodev    sockfs
nodev    usbfs
nodev    pipefs
nodev    anon_inodefs
nodev    inotifyfs
nodev    devpts
nodev    ramfs
nodev    hugetlbfs
    iso9660
nodev    pstore
nodev    mqueue
nodev    selinuxfs
    ext4
nodev    fuse
    fuseblk
nodev    fusectl

0x3: /proc/kcore: Represents the physical memory of the system stored in the core format

/proc/kcore: ELF 32-bit LSB core file Intel 80386, version 1 (SYSV), SVR4-style, from 'ro root=UUID=c03bcf41-af81-41b2-b476-e986f278bbb2 rd_NO_LUKS rd_NO_LVM LANG=en_U'

0x4: /proc/kmsg: This file can be used to log system messages

輸入指令

cat /proc/kmsg

命令列會進入訊息迴圈阻塞狀態,不斷列印出當前系統的的message,我們可以利用這個特性進行核心開發的除錯

0x5: /proc/loadavg: Load average numbers

顯示當前系統負載情況

0.00 0.00 0.00 1/275 24279

0x6: /proc/meminfo: report memory usage

MemTotal:        1938768 kB
MemFree:          593004 kB
Buffers:           78100 kB
Cached:           750600 kB
SwapCached:            0 kB
Active:           589528 kB
Inactive:         373588 kB
Active(anon):      48524 kB
Inactive(anon):    90908 kB
Active(file):     541004 kB
Inactive(file):   282680 kB
Unevictable:           0 kB
Mlocked:               0 kB
HighTotal:       1189832 kB
HighFree:         584536 kB
LowTotal:         748936 kB
LowFree:            8468 kB
SwapTotal:       4161528 kB
SwapFree:        4161528 kB
Dirty:                24 kB
Writeback:             0 kB
AnonPages:        134436 kB
Mapped:            70708 kB
Shmem:              5016 kB
Slab:             353944 kB
SReclaimable:      31848 kB
SUnreclaim:       322096 kB
KernelStack:        2184 kB
PageTables:         7208 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     5130912 kB
Committed_AS:     650372 kB
VmallocTotal:     122880 kB
VmallocUsed:        5908 kB
VmallocChunk:     103832 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:       12280 kB
DirectMap2M:      894976 kB

0x7: /proc/misc

229 fuse
223 uinput
184 microcode
 57 rfkill
 58 device-mapper
 59 network_throughput
 60 network_latency
 61 cpu_dma_latency
 62 crash
175 agpgart
144 nvram
228 hpet
231 snapshot
227 mcelog
 63 vga_arbiter

0x8: /proc/partitions: Lists the partitions and their device major and minor numbers

major minor  #blocks  name
   8        0   10485760 sda
   8        1     307200 sda1
   8        2    4161536 sda2
   8        3    6016000 sda3

0x9: /proc/stat: kernel statistics subdirectory

顯示和系統當前執行狀態有關的資訊

1. cpu: Jiffies spent in user mode, user mode with low priority, system mode, and idle.
2. disk: Four disk entries not yet implemented
3. page: The number of pages the system paged in and out.
4. swap: Swap pages that have been brought in and out.
5. intr: The number of interrupts received form the system boot
6. ctxt: The number of context switches that the system underwent.
7. btime: Boot time in seconds since Jan 1, 1970.

cat /proc/stat

cpu  3355 2034 14361 34172 957 143 75 0 0
cpu0 3355 2034 14361 34172 957 143 75 0 0
intr 313510 209 383 0 3 268 0 0 0 1 0 0 0 3578 0 0 0 2034 79701 478 294 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3014 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 ctxt 364763 btime 1406815679 processes 3447 procs_running 1 procs_blocked 0 softirq 520879 0 205379 252 298 79676 0 592 0 100 234582

0x10: /proc/swaps: A file defining swap partitions

顯示當前系統記憶體交換檔案

Filename    Type        Size          Used    Priority
/dev/sda2    partition    4161528        0    -1

0x11: /proc/tty

1. driver: A directory
    1. serial 
2. drivers: A file listing device drivers
/dev/tty             /dev/tty        5       0 system:/dev/tty
/dev/console         /dev/console    5       1 system:console
/dev/ptmx            /dev/ptmx       5       2 system
/dev/vc/0            /dev/vc/0       4       0 system:vtmaster
rfcomm               /dev/rfcomm   216 0-255 serial
serial               /dev/ttyS       4 64-95 serial
pty_slave            /dev/pts      136 0-1048575 pty:slave
pty_master           /dev/ptm      128 0-1048575 pty:master
unknown              /dev/tty        4 1-63 console

0x12: /proc/version

Linux version 2.6.32-431.20.5.el6.centos.plus.i686 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) ) #1 SMP Fri Jul 25 06:25:17 UTC 2014

0x13: /proc/sys/

The /proc/sys/ directory is different from others in /proc/ because it not only provides information about the system but also allows the system administrator to immediately enable and disable kernel features.

Relevant Link:

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s2-proc-dir-sys.html

 

6. /dev簡介

裝置檔案分為兩種: 塊裝置檔案(b)和字元裝置檔案(c),對於/dev我們需要明白,它不是裝置驅動,linux有自己的裝置驅動,/dev下的檔案只是訪問相應驅動的介面
裝置檔案一般存放在/dev目錄下,對常見裝置檔案作如下說明:

/dev/hd[a-t]:IDE裝置
/dev/sd[a-z]:SCSI裝置
/dev/fd[0-7]:標準軟碟機
/dev/md[0-31]:軟raid裝置
/dev/loop[0-7]:本地迴環裝置
/dev/ram[0-15]:記憶體
/dev/null:無限資料接收裝置,相當於黑洞
/dev/zero:無限零資源
/dev/tty[0-63]:虛擬終端
/dev/ttyS[0-3]:串列埠
/dev/lp[0-3]:並口
/dev/console:控制檯(tty)
/dev/fb[0-31]:framebuffer
/dev/cdrom => /dev/hdc
/dev/modem => /dev/ttyS[0-9]
/dev/pilot => /dev/ttyS[0-9]
/dev/random:隨機數裝置
/dev/urandom:隨機數裝置

0x1: tty(本地互動終端shell裝置)
"tty"這個詞源於Teletypes,或者teletypewriters,原來指的是電傳打字機,是通過序列線用印表機鍵盤通過閱讀和傳送資訊的東西,後 來這東西被鍵盤與顯示器取代,所以現在叫終端比較合適。
終端是一種字元型裝置,它有多種型別,通常使用tty來簡稱各種型別的終端裝置。
通常我們在linux下看到的控制檯(console)是由幾個裝置完成的。分別是

1. /dev/tty0
tty0就是/dev/console,由linux/drivers/char/console.c對應

2. /dev/tty1
3. /dev/tty2
tty1,tty2就是不同的虛擬終端(virtual console)。通常使用熱鍵alt+Fn來在這些虛擬終端之間進行切換。由和vt.c對應

4. /dev/tty3
5. /dev/tty4
6. /dev/tty5
7. /dev/tty6
...

0x2: pty(遠端登入互動終端shell裝置)

我們在遠端telnet到主機或使用xterm時也需要一個終端互動,這就是虛擬終端pty(pseudo-tty)

ll /dev/pts

/dev/pts是遠端登陸(telnet,ssh等)後建立的控制檯裝置檔案所在的目錄。由於可能有好幾千個使用者登陸,所以/dev/pts其實是動態生成的,不象其他裝置檔案是構建系統時就已經產生的硬碟節點(如果未使用devfs)

1. /dev/pts/0
第一個使用者登陸,console的裝置檔案為/dev/pts/0
2. /dev/pts/1
第二個為/dev/pts/1
3. 以此類推
//這裡的0、1、2、3不是具體的標準輸入或輸出,而是整個控制檯

Relevant Link:

http://blog.csdn.net/maopig/article/details/7195048
http://www.jz123.cn/text/1929468.html

 

7. 記憶體相關

0x1: /proc/iomem: I/O記憶體

zhenghan.zh@miser010249213142.yh $ cat /proc/iomem 
00010000-0009dbff : System RAM
0009dc00-0009ffff : reserved
000a0000-000bffff : Video RAM area
000c0000-000c8bff : Video ROM
000c9000-000c97ff : Adapter ROM
000c9800-000cb9ff : Adapter ROM
000f0000-000fffff : System ROM
00100000-dfffcfff : System RAM
  00200000-0047dd90 : Kernel code
  0047dd91-005c075f : Kernel data
dfffd000-dfffffff : reserved
f0000000-f1ffffff : 0000:00:02.0
f2000000-f2000fff : 0000:00:02.0
f2010000-f201ffff : 0000:00:02.0
f2020000-f2020fff : 0000:00:03.0
  f2020000-f2020fff : virtio-pci
f2030000-f203ffff : 0000:00:03.0
f2040000-f2040fff : 0000:00:04.0
  f2040000-f2040fff : virtio-pci
fffbc000-ffffffff : reserved
100000000-2132fffff : System RAM

 

Copyright (c) 2014 LittleHann All rights reserved

 

相關文章