Proc File System Introduction

xiaoxiao2021-03-06  75

The PROC file system is a pseudo file system that exists only in memory without occupying an existing space. It provides an interface to the operation of accessing system kernel data in a file system. Users and applications can get the system information through Proc, and can change certain parameters of the kernel. Due to the information of the system, if the process is dynamically changed, the Proc file system is dynamically read out the required information from the system, and submitted by the user or the application reads the proc file. Its directory structure is as follows: Directory Name Directory Content APM Advanced Power Management Information CMDLINE Cycle CPUInfo About CPU Information Devices (Block Device / Character Device) DMA Used DMS Channels FileSystems Supported file system Interrupts Interrupt Using IOPORTS I / O port Using KCORE kernel core impression KMSG kernel message KSYMS kernel symbol table loadavg load balancing LOCKS kernel lock MEMINFO memory information Misc Miscellaneous Modules List Mount Mounts Loaded file system Partitions system identification partition Table RTC Real Time Clock Slabinfo SLAB POLEL Info Stat Comprehensive Statistics Status Table S SWAPS Swaps Switch Space Utilization Version Nuclear Version Uptime System Normal Run Time is not all of these directories in your system, depending on your kernel configuration and load module. In addition, there are three important directories under / proc: NET, SCSI and SYS. The SYS directory is writable and can be used to access or modify the kernel parameters (see section), and NET and SCSI rely on kernel configuration. For example, if the system does not support SCSI, the SCSI directory does not exist. In addition to these described above, there are some directory named, which are processes. Each process currently run in the system has a corresponding directory under / proc, with a directory name, which is an interface to read the process information. The SELF directory is the information interface that reads the process itself, is a LINK. The name of the PROC file system is from it. The structure of the process directory is as follows: Directory Name Directory Content CMDLINE Command Line Parameters Environment Environment Variable Value FD A Directory Memation Contains All File Descript Memory Memory Used STAT Process Status Status Process Status in Human Readable Form CWD Current Work Directory Link EXE LINK to the Executable of this Process MAPS Memory Impression STATM Process Memory Status Information Root Link This process ROOT directory user If you want to view system information, you can use a 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 11: 8 XT-PIC I82365 12: 182918 XT-PIC Mouse 13: 1 XT-PIC FPU PS / 2 14: 1232265 XT-PIC IDE0 15: 7 XT-PIC IDE1 NMI: 0 2 Modifying the kernel parameters There is an interesting directory in the / proc file system: / proc / sys. It not only provides kernel information, but also modifies the kernel parameters to optimize your system. But you have to be very careful because it may cause the system to crash. It is best to find an irrelevant machine, and then apply it to your system after debugging. To change the parameters of the kernel, just redirect to the file with VI editing or ECHO parameter. Here's 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 optimize parameters You can write them into a script file so that it automatically completes the modification when the system is started. Load the PROC file system

For some procedures, the PROC file system must be provided in the virtual root environment. Since a file system can be loaded unlimited (more because PROC is a virtual file system), don't worry that the Proc file system has already loaded in your primary system.

We load the Proc file system to / prot, the command is as follows:

Mount Proc / Proc -T Proc

You are likely to see such a warning:

Warning: can't open / etc / fstab: No Such file or directory

Not enough memory

Don't worry, this is just because our system is still incomplete, some files have not yet been created. Mount itself is successful, we only care about this.

proc filesystem five major functions of: ZDNet China

Thursday, February 12 2004

2:51 pm

In Linux, you can use the PROC virtual file system to access various file information, including the currently running process and battery status. The PROC file system is virtual because it is created by memory and is dynamically updated when the system changes. To get access to system information, you should use standard file APIs, such as Fopen, FREAD, read appropriate files in the Proc file system. Start serious consideration