当前位置: 技术问答>linux和unix
\proc文件系统列表?
来源: 互联网 发布时间:2015-02-08
本文导语: proc文件系统列表的每一列代表什么意思? | /proc is a pseudo-filesystem which is used as an interface to kernel data struc- tures rather than reading and interpreting /dev/kmem. Most of it is...
proc文件系统列表的每一列代表什么意思?
|
/proc is a pseudo-filesystem which is used as an interface to kernel data struc-
tures rather than reading and interpreting /dev/kmem. Most of it is read-only, but
some files allow kernel variables to be changed.
The following outline gives a quick tour through the /proc hierarchy.
[number]
There is a numerical subdirectory for each running process; the subdirectory
is named by the process ID. Each contains the following pseudo-files and
directories.
devices
Text listing of major numbers and device groups. This can be used by
MAKEDEV scripts for consistency with the kernel.
dma This is a list of the registered ISA DMA (direct memory access) channels in
use.
driver Empty subdirectory.
execdomains
List of the execution domains (ABI personalities).
fb Frame buffer information when CONFIG_FB is defined during kernel compila-
tion.
filesystems
A text listing of the filesystems which were compiled into the kernel.
Incidentally, this is used by mount(1) to cycle through different filesys-
tems when none is specified.
ide ide exists on systems with the ide bus. There are directories for each ide
channel and attached device. Files include:
interrupts
This is used to record the number of interrupts per each IRQ on (at least)
the i386 architechure. Very easy to read formatting, done in ASCII.
iomem I/O memory map in Linux 2.4.
ioports
This is a list of currently registered Input-Output port regions that are in
use.
kcore This file represents the physical memory of the system and is stored in the
ELF core file format. With this pseudo-file, and an unstripped kernel
(/usr/src/linux/vmlinux) binary, GDB can be used to examine the current
state of any kernel data structures.
The total length of the file is the size of physical memory (RAM) plus 4KB.
kmsg This file can be used instead of the syslog(2) system call to log kernel
messages. A process must have superuser privileges to read this file, and
only one process should read this file. This file should not be read if a
syslog process is running which uses the syslog(2) system call facility to
log kernel messages.
Information in this file is retrieved with the dmesg(8) program.
tures rather than reading and interpreting /dev/kmem. Most of it is read-only, but
some files allow kernel variables to be changed.
The following outline gives a quick tour through the /proc hierarchy.
[number]
There is a numerical subdirectory for each running process; the subdirectory
is named by the process ID. Each contains the following pseudo-files and
directories.
devices
Text listing of major numbers and device groups. This can be used by
MAKEDEV scripts for consistency with the kernel.
dma This is a list of the registered ISA DMA (direct memory access) channels in
use.
driver Empty subdirectory.
execdomains
List of the execution domains (ABI personalities).
fb Frame buffer information when CONFIG_FB is defined during kernel compila-
tion.
filesystems
A text listing of the filesystems which were compiled into the kernel.
Incidentally, this is used by mount(1) to cycle through different filesys-
tems when none is specified.
ide ide exists on systems with the ide bus. There are directories for each ide
channel and attached device. Files include:
interrupts
This is used to record the number of interrupts per each IRQ on (at least)
the i386 architechure. Very easy to read formatting, done in ASCII.
iomem I/O memory map in Linux 2.4.
ioports
This is a list of currently registered Input-Output port regions that are in
use.
kcore This file represents the physical memory of the system and is stored in the
ELF core file format. With this pseudo-file, and an unstripped kernel
(/usr/src/linux/vmlinux) binary, GDB can be used to examine the current
state of any kernel data structures.
The total length of the file is the size of physical memory (RAM) plus 4KB.
kmsg This file can be used instead of the syslog(2) system call to log kernel
messages. A process must have superuser privileges to read this file, and
only one process should read this file. This file should not be read if a
syslog process is running which uses the syslog(2) system call facility to
log kernel messages.
Information in this file is retrieved with the dmesg(8) program.
|
PROC文件系统是一个伪文件系统,它的文件和目录是由Linux 操作系统核心提供的,以文件系统的方式为访问系统内核数据的操作提供接口,它们不占用磁盘上的任何空间,有了这些文件和目录, 用户可以更容易的了解操作系统核心或各个进程的状态,并能对系统的一些参数进行配置。比如,一个系统内能打开的文件数最大缺省是1024,即系统最多能同时打开1024个文件,这在使用Linux做多用户的服务器时是不够用的,通过对/PROC下文件的修改可以在不修改核心,甚至不启动机器的情况下改变这个缺省值。由于系统的信息,如进程,是动态改变的,所以用户或应用程序读取PROC文件时,PROC文件系统是动态从系统内核读出所需信息并提交的。它的目录结构如下:
目录名称 目录内容
apm Advanced power management info
Cmdline Kernel command line
Cpuinfo Info about the CPU
Devices Available devices (block and character)
Dma Used DMS channels
Filesystems Supported filesystems
Interrupts Interrupt usage
Ioports I/O port usage
Kcore Kernel core image
Kmsg Kernel messages
Ksyms Kernel symbol table
Loadavg Load average
Locks Kernel locks
Meminfo Memory info
Misc Miscellaneous
Modules List of loaded modules
Mounts Mounted filesystems
Partitions Table of partitions known to the system
Rtc Real time clock
Slabinfo Slab pool info
Stat Overall statistics
Swaps Swap space utilization
Version Kernel version
Uptime System uptime
并不是所有这些目录在你的系统中都有,这取决于你的内核配置和装载的模块。另外,在/proc下还有三个很重要的目录:net,scsi和sys。Sys目录是可写的,可以通过它来访问或修改内核的参数,而net和scsi则依赖于内核配置。例如,如果系统不支持scsi,则scsi目录不存在。
除了以上介绍的这些,还有的是一些以数字命名的目录,它们是进程目录。系统中当前运行的每一个进程都有对应的一个目录在/PROC下,以进程的PID号为目录名,它们是读取进程信息的接口。而self目录则是读取进程本身的信息接口,是一个link。Proc文件系统的名字就是由之而起。进程目录的结构如下:
目录名称 目录内容
Cmdline Command line arguments
Environ Values of environment variables
Fd Directory, which contains all file descriptors
Mem Memory held by this process
Stat Process status
Status Process status in human readable form
Cwd Link to the current working directory
Exe Link to the executable of this process
Maps Memory maps
Statm Process memory status information
Root Link to the root directory of this process
用户如果要查看系统信息,可以用cat命令。例如:
> cat /proc/interrupts
CPU0
0: 8728810 XT-PIC timer
1: 895 XT-PIC keyboard
2: 0 XT-PIC cascade
3: 531695 XT-PIC aha152x
4: 2014133 XT-PIC serial
5: 44401 XT-PIC pcnet_cs
8: 2 XT-PIC rtc
11: 8 XT-PIC i82365
12: 182918 XT-PIC PS/2 Mouse
13: 1 XT-PIC fpu
14: 1232265 XT-PIC ide0
15: 7 XT-PIC ide1
NMI: 0
2.修改内核参数
在/proc文件系统中有一个有趣的目录:/proc/sys。它不仅提供了内核信息,而且可以通过它修改内核参数,来优化你的系统。但是你必须很小心,因为可能会造成系统崩溃。最好是先找一台无关紧要的机子,调试成功后再应用到你的系统上。
要改变内核的参数,只要用vi编辑或echo参数重定向到文件中即可。下面有一个例子:
# cat /proc/sys/fs/file-max
4096
# echo 8192 > /proc/sys/fs/file-max
# cat /proc/sys/fs/file-max
8192
如果你优化了参数,则可以把它们写成脚本文件,使它在系统启动时自动完成修改。
目录名称 目录内容
apm Advanced power management info
Cmdline Kernel command line
Cpuinfo Info about the CPU
Devices Available devices (block and character)
Dma Used DMS channels
Filesystems Supported filesystems
Interrupts Interrupt usage
Ioports I/O port usage
Kcore Kernel core image
Kmsg Kernel messages
Ksyms Kernel symbol table
Loadavg Load average
Locks Kernel locks
Meminfo Memory info
Misc Miscellaneous
Modules List of loaded modules
Mounts Mounted filesystems
Partitions Table of partitions known to the system
Rtc Real time clock
Slabinfo Slab pool info
Stat Overall statistics
Swaps Swap space utilization
Version Kernel version
Uptime System uptime
并不是所有这些目录在你的系统中都有,这取决于你的内核配置和装载的模块。另外,在/proc下还有三个很重要的目录:net,scsi和sys。Sys目录是可写的,可以通过它来访问或修改内核的参数,而net和scsi则依赖于内核配置。例如,如果系统不支持scsi,则scsi目录不存在。
除了以上介绍的这些,还有的是一些以数字命名的目录,它们是进程目录。系统中当前运行的每一个进程都有对应的一个目录在/PROC下,以进程的PID号为目录名,它们是读取进程信息的接口。而self目录则是读取进程本身的信息接口,是一个link。Proc文件系统的名字就是由之而起。进程目录的结构如下:
目录名称 目录内容
Cmdline Command line arguments
Environ Values of environment variables
Fd Directory, which contains all file descriptors
Mem Memory held by this process
Stat Process status
Status Process status in human readable form
Cwd Link to the current working directory
Exe Link to the executable of this process
Maps Memory maps
Statm Process memory status information
Root Link to the root directory of this process
用户如果要查看系统信息,可以用cat命令。例如:
> cat /proc/interrupts
CPU0
0: 8728810 XT-PIC timer
1: 895 XT-PIC keyboard
2: 0 XT-PIC cascade
3: 531695 XT-PIC aha152x
4: 2014133 XT-PIC serial
5: 44401 XT-PIC pcnet_cs
8: 2 XT-PIC rtc
11: 8 XT-PIC i82365
12: 182918 XT-PIC PS/2 Mouse
13: 1 XT-PIC fpu
14: 1232265 XT-PIC ide0
15: 7 XT-PIC ide1
NMI: 0
2.修改内核参数
在/proc文件系统中有一个有趣的目录:/proc/sys。它不仅提供了内核信息,而且可以通过它修改内核参数,来优化你的系统。但是你必须很小心,因为可能会造成系统崩溃。最好是先找一台无关紧要的机子,调试成功后再应用到你的系统上。
要改变内核的参数,只要用vi编辑或echo参数重定向到文件中即可。下面有一个例子:
# cat /proc/sys/fs/file-max
4096
# echo 8192 > /proc/sys/fs/file-max
# cat /proc/sys/fs/file-max
8192
如果你优化了参数,则可以把它们写成脚本文件,使它在系统启动时自动完成修改。
|
每个以数字为名称的目录代表一个进程,
目录里的文件中包含关于该进程的一些信息。
目录里的文件中包含关于该进程的一些信息。