/Proc file system overview

Source: Internet
Author: User

From: http://blog.csdn.net/qinzhonghello/archive/2009/03/31/4038191.aspx

The proc file system is a pseudo-file system that only exists in the memory and does not occupy the external storage space. It provides interfaces for accessing system kernel data in the form of a file system. Users and applications can obtain system information through proc and change certain kernel parameters. Because system information, such as processes, is dynamically changed, when a user or application reads the proc file, the proc file system dynamically reads the required information from the system kernel and submits it. Its directory structure is as follows:

Directory Name directory content
APM Advanced Power Management Information
Cmdline kernel command line
Cpuinfo CPU Information
Devices available for devices (Block devices/character devices)
DMA used DMS Channels
File systems supported by filesystems
Interrupts interruption
Ioports I/O port usage
Core impressions of kcore
Kmsg kernel message
Ksyms kernel symbol table
Loadavg Load Balancing
Locks kernel lock
Meminfo memory information
Misc Miscellaneous
List of modules loaded by modules
File System loaded by mounts
Partition tables recognized by the partitions System
RTC real time clock
Slabinfo slab pool info
Stat comprehensive statistics Status table
SWAps space utilization
Version kernel version
Uptime system normal running time
Not all of these directories are available in your system, depending on your Kernel configuration and loaded modules. In addition, there are three important directories in/proc: net, SCSI, and SYS. The sys directory is writable and can be used to access or modify kernel parameters (see the following section). Net and SCSI depend on Kernel configurations. For example, if the system does not support SCSI, the SCSI directory does not exist.
In addition to the above descriptions, there are also some directories named by numbers, which are process directories. Each process currently running in the system has a corresponding directory under/proc, with the process PID as the directory name. They are interfaces for reading process information. The self directory is an interface for reading information about the process itself and a link. The name of the proc file system starts from. The process directory structure is as follows:
Directory Name directory content
Cmdline command line parameters
Environ environment variable value
Fd a directory containing all file descriptors
Memory utilization of MEM Process
Stat Process status
Status Process status in human readable form
CWD current working directory Link
EXE link to the executable of this Process
Maps memory impressions
Statm process memory status information
Root link to the root directory of the process
To view system information, run the cat command. For example:
>; 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
XT-PIC i82365
XT-PIC mouse 12: 182918
13: 1 XT-PIC fpu ps/2
14: 1232265 XT-PIC ide0
15: 7 XT-PIC ide1
NMI: 0
2. Modify Kernel Parameters
There is an interesting directory in the/proc file system:/proc/sys. It not only provides kernel information, but also allows you to modify kernel parameters to optimize your system. But you must be very careful because it may cause system crashes. It is best to first find an irrelevant machine and apply it to your system after successful debugging.
To change the kernel parameters, you only need to use the VI editing or ECHO parameter to redirect to the file. The following is an example:
# Cat/proc/sys/fs/file-max
4096
# Echo 8192>;/proc/sys/fs/file-max
# Cat/proc/sys/fs/file-max
8192
If you have optimized the parameters, you can write them as script files so that they are automatically modified when the system starts.

××××××××××××××××××××××××××××××××××
The/proc file system is a false file system. It does not exist on a disk. Instead, the core is generated in the memory. Used to provide information about the system (originally about processes, hence the name ). The following describes some of the most important files and directories. The/proc file system is described in more detail on the proc man page.

/Proc/1
The information directory of process 1. Each process has a directory named process number under/proc.
/Proc/cpuinfo
Processor information, such as type, manufacturer, model, and performance.
/Proc/devices
List of device drivers of the core configurations currently running.
/Proc/DMA
Displays the currently used DMA channel.
/Proc/filesystems
Core configuration file system.
/Proc/interrupts
Displays the interruption of use, and how to handle the each there have been.
/Proc/ioports
The currently used I/O port.
/Proc/kcore
System physical memory image. It is identical to the physical memory size, but does not actually occupy so much memory; it is generated on the fly as programs access it. (Remember: Unless you copy it to somewhere, nothing in/proc occupies any disk space .)
/Proc/kmsg
Core Output Message. Also sent to syslog.
/Proc/ksyms
Core symbol table.
/Proc/loadavg
System "average load"; three meaningless indicators indicate the current workload of the system.
/Proc/meminfo
Memory usage information, including physical memory and swap.
/Proc/modules
Which core modules are currently loaded.
/Proc/Net
Network Protocol status information.
/Proc/self
Symbolic connection to the process directory of the program to view/proc. When two processes view/proc, the connection is different. This allows the program to obtain its own process directory.
/Proc/STAT
Different States of the system, such as the number of page faults since the system was booted.
/Proc/uptime
The duration of system startup.
/Proc/version
Core version.

Note that all the above files provide readable text files, which may sometimes be difficult to read. Many commands have been formatted to make it easier to read. For example, the free program reads/proc/meminfo and converts the number of bytes to kilobytes (and adds some information ).
×××××××××××××××××××××××××××××××××
You can view the system information without restarting CMOS. This is one of the highlights of/proc.
The/proc file system is a window for understanding system information. This article will discuss it and give an example of the internal structure of the/proc file system. The/proc file system is a virtual file system, and the seemingly existing files are not actually on the hard disk. In fact,/proc is a window for you to understand your system. It actually exists in the memory. For example,/proc/cpuinfo contains information about the processor, such as the type, manufacturer, and model. An example of an output is as follows: [Albert @ www tmp] $ CAT/proc/cpuinfo processor: 1 vendor_id: genuineintel CPU family: 6 model: 7 model name: Pentium III (Katmai) stepping: 3 CPU MHz: 501.146145 cache size: 512 KB fdiv_bug: No hlt_bug: No sep_bug: No f00f_bug: No coma_bug: No FPU: Yes fpu_exception: Yes cpuid level: 2 WP: yes flags: fpu vme de pse tsc msr pae mce cx8 APIC Sep mtrr pge mca cmov Pat limit 36 MMX osfxsr kni B Ogomips: 499.71/proc/devices lists the device drivers/proc/interrupts configured in the kernel to list the interrupt numbers in use, which is useful in the diagnosis of hardware conflicts. /Proc/kmsg is the kernel output information, which is also sent to syslog. /Proc/meminfo lists the system memory conditions, including physical memory and swap zone. An example of an output is as follows: [Albert @ www tmp] $ CAT/proc/meminfo Total: used: Free: shared: buffers: cached: Mem: 263806976 206512128 57294848 39387136 92950528 swap: 279617536 7405568 272211968 memtotal: 257624 kb memfree: 55952 kb memshared: 38464 kb buffers: 90772 kb cached: 54852 kb swaptotal: 273064 kb swapfree: 265832 KB/proc/modules output the currently loaded kernel module. The/proc/NET directory contains the system network configuration information. I will write another article. The/proc/PCI list system's PCI devices can be seen that the/proc file system is very useful. In fact, some of the commands we usually use come from/proc. For example, partial uname-A information comes from/proc/version, and partial uptime information comes from/proc/uptime and/proc/loadavg. Therefore, the next time someone asks you about the machine's clock speed, there is no need to rummaging through the Cabinet to find the manual. Everything is in the/proc file system.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.