1./proc Directory
The Linux kernel provides a mechanism for accessing kernel internal data structures and changing kernel settings at run time through the/proc file system. The proc file system is a pseudo-file system that only exists in memory and does not occupy external memory space. It provides an interface for accessing system kernel data in a file system manner.
Users and applications can get system information through proc, and can change certain parameters of the kernel. Because the information of the system, such as the process, is dynamically changed, so when the user or application reads the proc file, the proc file system dynamically reads the required information from the system kernel and submits it. These files or subfolders listed below are not always present in your system, depending on your kernel configuration and the modules that are loaded. 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 kernel parameters, while net and SCSI depend on the kernel configuration. For example, if the system does not support SCSI, the SCSI directory does not exist.
In addition to the above, there are a number of directories named, they are the process directory. Each process currently running in the system has a corresponding directory under/proc, with the PID number of the process as the directory name, which is the interface to read the process information. The self directory is the information interface of the read process itself and is a link.
2. Sub-Files or subfolders
/proc/buddyinfo how many blocks of each order in each memory area are available, related to memory fragmentation issues
/proc/cmdline parameter information passed to kernel at startup
/proc/cpuinfo CPU Information
/proc/crypto all installed cryptographic passwords and details used by the kernel
/proc/devices devices that have been loaded and sorted
/PROC/DMA List of ISA DMA channels that have been registered for use
/proc/execdomains the Linux kernel currently supports execution domains
/PROC/FB Frame buffer device list, including number and drive to control it
File system types currently supported by the/proc/filesystems kernel
/proc/interrupts number of IRQ interrupts in the x86 architecture
/proc/iomem the current mapping of each physical device in system memory
/proc/ioports the registration port range used by the input and output of a device
/proc/kcore represents the physical memory of the system, stored as the core file format, which shows the number of bytes, equal to the RAM size plus 4KB
/proc/kmsg records the information generated by the kernel, which can be handled by/SBIN/KLOGD or/BIN/DMESG
/PROC/LOADAVG load status based on CPU and IO status over a period of time, related to the uptime command
List of files locked by the/proc/locks kernel
/proc/mdstat multi-drive, RAID configuration information (Md=multiple disks)
/proc/meminfo information about RAM usage
/proc/misc other major equipment (device Number 10) on the registered driver
/proc/modules List of all modules loaded into the kernel
/proc/mounts all mounts used in the system
Memory Type Range Registers (MTRRS) used by the/PROC/MTRR system
Block allocation information in a/proc/partitions partition
List of PCI devices in the/PROC/PCI system
/proc/slabinfo Slab cache information for all activities in the system
/proc/stat All CPU activity information
/proc/sysrq-trigger when using the echo command to write this file, the remote root user can perform most of the system request critical commands as if they were executed on the local terminal. To write this file, the/PROC/SYS/KERNEL/SYSRQ cannot be set to 0. This file is unreadable to root.
How long has the/proc/uptime system been running?
Use of/proc/swaps swap space
/proc/version Linux kernel version and GCC version
/proc/bus system bus information such as PCI/USB, etc.
/proc/driver Driver Information
/PROC/FS File System Information
/proc/ide IDE Device Information
/PROC/IRQ Interrupt Request Device information
/proc/net Network card Device information
/PROC/SCSI SCSI Device Information
/proc/tty TTY Device Information
/proc/net/dev Display of network adapters and statistical information
/proc/vmstat Virtual Memory Statistics
/proc/vmcore memory image when kernel panic
/proc/diskstats Obtaining disk information
/proc/schedstat Kernel Scheduler Statistics
/proc/zoneinfo displays statistics for memory space, which is useful for analyzing virtual memory behavior
The following is the information for process n in the/proc directory
/proc/n PID for process information of N
/proc/n/cmdline Process Start command
/PROC/N/CWD linking to the current working directory of the process
/proc/n/environ Process environment variable list
/proc/n/exe the execution command file linked to the process
/PROC/N/FD contains all the file descriptors associated with the process
/proc/n/maps memory-mapped information related to processes
/proc/n/mem refers to the memory that is held by the process, unreadable
/proc/n/root linking to the root of a process
Status of the/proc/n/stat process
The state of the memory used by the/PROC/N/STATM process
/proc/n/status process state information, more readable than STAT/STATM
/proc/self Link to the currently running process
3. Example
3.1/proc/
[email protected]: ~$ ls/proc/
1 16819 21242 2180 2494 8768 interrupts partitions
16820 21244 2181 2524 885 iomem sched_debug
11740 17901 21245 21810 2525 ACPI Ioports SCSI
11742 17903 21247 21812 3 asound IRQ Self
11743 17904 2131 21813, Buddyinfo kallsyms slabinfo
13452 18362 21319 21923 4 bus kcore stat
13454 18364 2132 2193 cgroups key-users swaps
13455 18365 2139 21933 cmdline kmsg sys
149 19451 2142 2209 5 cpuinfo kpagecount Sysrq-trigger
19453 21572 2212 5330 Crypto kpageflags SYSVIPC
151 19454 21574 2219 596 devices Loadavg timer_list
2 21575 2243 597 diskstats Locks timer_stats
15771 2083 2158 2260 6 DMA Meminfo TTY
15773 2092 21625 2261 617 Driver Misc Uptime
15774 2101 21627 2262 619 execdomains modules version
16232 21112 21628 2263 7 FB Mounts Vmallocinfo
16234 21115 2165 2264 804 filesystems mtrr Vmstat
16235 21116 2167 2265 8765 FS Net Zoneinfo
16811 2112 2177 2338 8767 IDE Pagetypeinfo
3.2/proc/sys
System Information and Kernel parameters
[email protected]: ~$ ls/proc/sys
Debug Dev FS Kernel net VM
3.3/proc/net
Network Card Device Information
[email protected]: ~$ ls/proc/net
Anycast6 ip6_flowlabel netfilter raw6 sockstat6 udplite
ARP ip6_mr_cache netlink Route softnet_stat Udplite6
Dev ip6_mr_vif netstat rt6_stats stat Unix
Dev_mcast ip_mr_cache packet Rt_acct TCP VLAN
DEV_SNMP6 ip_mr_vif Protocols Rt_cache TCP6 Wireless
If_inet6 ipv6_route psched SNMP tr_rif
IGMP mcfilter ptype snmp6 UDP
IGMP6 Mcfilter6 Raw Sockstat UDP6
3.4/proc/scsi
SCSI Device Information
[email protected]: ~$ LS/PROC/SCSI
Device_info SCSI
3.5/proc/modules
List of all modules loaded into the kernel
[email protected]: ~# cat/proc/modules
Bdspboard 8486 2 Dspcontrol, Live 0xe134c000
Dspcontrol 9575 1 Clkmon, Live 0xe135b000
Clkmon 6765 1-live 0xe136c000
Diagint 6635 1-live 0xe1379000
Bdsprio 10775 2 srioif,tsi577, Live 0xe9389000
tsi577 17998 1 srioif, Live 0xe939e000
Srioif 7329 0-live 0xe93b2000
Linux_kernel_bde 54666 1 Linux_user_bde, Live 0xf1417000 (P)
Linux_user_bde 17849 0-live 0xf1427000 (P)
[email protected]: ~#
3.6/proc/devices
Devices that have been loaded and categorized
[email protected]: ~# cat/proc/devices
Character Devices:
1 mem
2 Pty
3 Ttyp
4/dev/vc/0
4 TTY
4 TTYs
5/dev/tty
5/dev/console
5/dev/ptmx
7 vcs
Ten Misc
Input
About
Mtd
Linux-user-bde2
117 Linux-kernel-bde2
126 Linux-user-bde
127 Linux-kernel-bde
Ptm
136 pts
usb
189 Usb_device
245 Ext_alarm
251 Ipmidev
252 Usb_endpoint
253 Usbmon
254 RTC
Block Devices:
1 RAMDisk
8 SD
Mtdblock
Sd
Sd
Sd
The SD
Sd
Sd
Sd
Sd
129 SD
Sd
131 SD
Sd
133 SD
134 SD
135 SD
[email protected]: ~#
3.7/proc/partitions
Block allocation information in a partition
[email protected]: ~# cat/proc/partitions
Major Minor #blocks name
0 mtdblock0
1 Mtdblock1
2 123904 Mtdblock2
3 4096 Mtdblock3
4 1024x768 Mtdblock4
5 1024x768 Mtdblock5
6 Mtdblock6
7 Mtdblock7
8 123904 Mtdblock8
9 4096 Mtdblock9
Mtdblock10
Mtdblock11
1048576 mtdblock12
[email protected]: ~#
3.8/proc/version
Linux kernel version and GCC version
[email protected]: ~# cat/proc/version
Linux version 2.6.34.6-wr4.0.0.0_standard ([email protected]) (GCC version 4.4.1 (Wind River Linux sourcery g++ 4 .4-291) #1 SMP PREEMPT Fri Nov 16:07:47 CST 2010
[email protected]: ~#
3.9/proc/sys/fs/file-max
This file specifies the maximum number of file handles that can be allocated. If the user gets an error message stating that the maximum number of open files has been reached so that they cannot open more files, you may need to increase the value. You can set this value to any number of files, and you can change the value by writing a new numeric value to the file. The default setting is 4096.
Change the kernel parameters and redirect to the file with vi edit or echo parameters.
# Cat/proc/sys/fs/file-max
4096
# echo 8192 >/proc/sys/fs/file-max
# Cat/proc/sys/fs/file-max
8192
If the parameters are optimized, they can be written as added to the file rc.local, allowing it to complete the modification automatically when the system starts.
Go Introduction to the/proc directory under Linux