Linux proc Directory The role of files or subfolders _linux

Source: Internet
Author: User
Tags data structures echo command numeric value readable

I. Introduction to the LINUX/PROC catalogue
The Linux kernel provides a mechanism for accessing kernel internal data structures and changing kernel settings through the/proc file system at run time. Proc File system is a pseudo file system, it only exists in memory, and does not occupy the storage space. It provides an interface to the operation of accessing system kernel data in a file system manner.
Users and applications can get information about the system through proc and can change some of the kernel's parameters. Because the information of the system, such as the process, is dynamically changed, so the user or application reads the proc file, the proc file system is dynamically reading the required information from the system kernel and submitting it. The files or subfolders listed below are not all present in your system, depending on your kernel configuration and loaded modules. 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 some numbers-named directories, which are the process catalogs. Each process currently running in the system has a corresponding directory under/proc, with the process's PID number as the directory name, which is the interface for reading process information. The self directory is the information interface that reads the process itself, and is a link.
two. The role of a child file or subfolder of the/proc directory
/proc/buddyinfo How many pieces of each order in each memory area are available, and memory fragmentation issues
/proc/cmdline parameter information passed to kernel at startup
/proc/cpuinfo information about the CPU
All installed encrypted passwords and details used by the/proc/crypto kernel
/proc/devices devices that have been loaded and sorted
/PROC/DMA the list of ISA DMA channels that are registered for use
/proc/execdomains Linux kernel currently supported execution domains
/PROC/FB Frame buffer device list, including quantity and control of its driver
File system types currently supported by the/proc/filesystems kernel
/proc/interrupts the number of per IRQ interrupts in the x86 schema
/proc/iomem the current mapping of each physical device in system memory
/proc/ioports the registered 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 ram size plus 4KB
/proc/kmsg records kernel-generated information that can be handled by/SBIN/KLOGD or/BIN/DMESG
/proc/loadavg the state of the load based on CPU and IO over a period of time, related to the uptime command
/proc/locks kernel-locked file list
/proc/mdstat multiple hard drives, RAID configuration information (Md=multiple disks)
Information about the use of/proc/meminfo RAM
/proc/misc driver registered on other major equipment (unit Number 10)
/proc/modules the list of all modules loaded into the kernel
All mounts used in the/proc/mounts 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
When/proc/sysrq-trigger uses the echo command to write this file, the remote root user can perform most of the system request-critical commands as if they were performed at the local terminal. To write to this file, you need to set the/PROC/SYS/KERNEL/SYSRQ to 0. This file is not readable for 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 (buses) 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 network adapters and statistics
/proc/vmstat Virtual Memory Statistics
Memory image when/proc/vmcore kernel panic
/proc/diskstats Get disk information
/proc/schedstat Kernel Scheduler Statistics
/proc/zoneinfo Displays the memory space statistics and is useful for analyzing virtual memory behavior
The following is information about process n in the/proc directory
Process information for/proc/n PID N
/proc/n/cmdline Process Start command
/PROC/N/CWD link to the current working directory of the process
/proc/n/environ Process Environment Variables 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 held by the process and cannot be read
/proc/n/root link to the root directory of the process
/proc/n/stat the status of a 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 a currently running process
Three. Actual Operation Example
1. List all the files under/proc/

Copy Code code as follows:
yafang@qa:~$ ls/proc/
1 16819 21242 2180 2494 8768 interrupts partitions
116 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
13452 18362 21319 21923 4 bus kcore stat
13454 18364 2132 2193 cgroups key-users swaps
13455 18365 2139 21933 cmdline sys
149 19451 2142 2209 5 cpuinfo Kpagecount
19453 21572 2212 5330 Crypto Kpageflags
151 19454 21574 2219 596 devices Loadavg timer_list
152 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 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

2. View system Information and kernel parameters
Copy Code code as follows:
yafang@qa:~$ Ls/proc/sys
Debug Dev FS kernel net Vm[code]
3. View network card device information
[code]yafang@qa:~$ 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

4. View SCSI Device Information
Copy Code code as follows:
yafang@qa:~$ LS/PROC/SCSI
Device_info SCSI

5. View the list of all modules loaded into the kernel
Copy Code code as follows:

root@bdsp-a-2-1-2:~# 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)
root@bdsp-a-2-1-2:~#

6. View the devices that have been loaded and categorize them
Copy Code code as follows:

root@bcnmb-a:~# 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
I2c
Mtd
116 Linux-user-bde2
117 Linux-kernel-bde2
126 Linux-user-bde
127 Linux-kernel-bde
128 PTM
136 pts
180 usb
189 Usb_device
245 Ext_alarm
251 Ipmidev
252 Usb_endpoint
253 Usbmon
254 RTC

Block devices:
1 RAMDisk
8 SD
Mtdblock
The SD
Sd
The SD
Sd
The SD
Sd
Sd
128 SD
129 SD
130 SD
131 SD
132 SD
The SD
134 SD
135 SD

root@bcnmb-a:~#


7. View block allocation information in a partition
Copy Code code as follows:

root@bdsp-a-2-1-2:~# cat/proc/partitions
Major Minor #blocks name
0 mtdblock0
1 Mtdblock1
2 123904 Mtdblock2
3 4096 Mtdblock3
4 1024 Mtdblock4
5 1024 MTDBLOCK5
6 Mtdblock6
7 Mtdblock7
8 123904 Mtdblock8
9 4096 Mtdblock9
1024 MTDBLOCK10
1024 MTDBLOCK11
1048576 mtdblock12
root@bdsp-a-2-1-2:~#

8. View Linux kernel version and GCC version
Copy Code code as follows:
root@bdsp-a-2-1-2:~# cat/proc/version
Linux version 2.6.34.6-wr4.0.0.0_standard (satomi@charliebrown) (GCC version 4.4.1 (wind River Linux sourcery g++ 4.4-291) ) #1 SMP preempt Fri Nov 16:07:47 CST 2010
root@bdsp-a-2-1-2:~#

9./proc/sys/fs/file-max
This file specifies the maximum number of file handles that can be allocated. You may need to increase this value if the user gets an error message stating that they cannot open more files because the number of open files has reached the maximum. You can set this value to have 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, using the vi edit or echo parameters to redirect to the file.
Copy Code code as follows:
# Cat/proc/sys/fs/file-max
4096
# echo 8192 >/proc/sys/fs/file-max
# Cat/proc/sys/fs/file-max
8192

If parameters are optimized, they can be written to add to the file rc.local so that it automatically completes the modification when the system starts.


Other examples:

1:[root@gechong proc]# More/proc/cmdline
Displays the kernel-initiated command line
2:[root@gechong proc]# Cat/proc/cpuinfo
Show CPU Information
3:[root@gechong proc]# cat/proc/devices
Displays the main device numbers for characters and block devices and the name of the device assigned to these device numbers
4:[root@gechong proc]# CAT/PROC/DMA
Displays the DMA channels that the driver retains and the name of the driver that retains them
5:[root@gechong proc]# More/proc/filesystems
Shows the type of file system available for use, one line of type
6:[root@gechong proc]# more/proc/interrupts
Each row has a reserved interrupt, which is: Interrupt number interrupt number The driver name of the registration interrupt
7:[root@gechong proc]# More/proc/ioports
Shows I/O-related device drives such as disk drives, Ethernet cards, sound card devices, etc.

Related Article

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.