The/proc directory on a Linux system is a file system, the proc file system. Unlike other common file systems,/proc is a pseudo-file system (also known as a virtual file system) that stores a series of special files that are currently running on the kernel, which users can use to view information about system hardware and the processes currently running. You can even change the running state of the kernel by changing some of these files.
Based on the particularity of the/proc file system as described above, its files are often referred to as virtual files and have some unique features. For example, some of these files will return a lot of information when viewed using the view command, but the size of the file itself will be displayed as 0 bytes. In addition, the time and date properties of most files in these special files are usually the current system time and date, which is related to their being refreshed (stored in RAM) at any time.
For ease of viewing and use, these files are typically stored in different directories or even subdirectories according to their relevance, such as the/PROC/SCSI directory where information about all SCSI devices on the current system is stored, and information about the processes currently running on the system is stored in/proc/n. , where n is a running process (as you can imagine, its associated directory disappears after a process has ended).
Most virtual files can be viewed using File view commands such as cat, more, or less, and some of the file information can be seen at a glance, but the information on the file is not very readable. However, these poorly readable files can perform well when using some commands such as APM, free, LSPCI, or top view.
I. Introduction to common Files in the process directory
The/proc directory contains a number of digitally named subdirectories that represent the process number of the process that the system is currently running, containing multiple information files related to the corresponding process.
[Email protected] ~]# Ll/proc
Total 0
Dr-xr-xr-x 5 root root 0 Feb 8 17:08 1
Dr-xr-xr-x 5 root root 0 Feb 8 17:08 10
Dr-xr-xr-x 5 root root 0 Feb 8 17:08 11
Dr-xr-xr-x 5 root root 0 Feb 8 17:08 1156
Dr-xr-xr-x 5 root root 0 Feb 8 17:08 139
Dr-xr-xr-x 5 root root 0 Feb 8 17:08 140
Dr-xr-xr-x 5 root root 0 Feb 8 17:08 141
Dr-xr-xr-x 5 root root 0 Feb 8 17:09 1417
Dr-xr-xr-x 5 root root 0 Feb 8 17:09 1418
Listed above are some of the process-related directories in the/proc directory, each of which is a file that contains information about the processes themselves. The following is a related file of a PID 2674 process SASLAUTHD running on the author system (RHEL5.3), some of which are in each process, and are described later in this article.
[Email protected] ~]# ll/proc/2674
Total 0
Dr-xr-xr-x 2 root root 0 Feb 8 17:15 attr
-R--------1 root root 0 Feb 8 17:14 auxv
-r--r--r--1 root root 0 Feb 8 17:09 cmdline
-rw-r--r--1 root root 0 Feb 8 17:14 coredump_filter
-r--r--r--1 root root 0 Feb 8 17:14 cpuset
lrwxrwxrwx 1 root root 0 Feb 8 17:14 CWD--/VAR/RUN/SASLAUTHD
-R--------1 root root 0 Feb 8 17:14 environ
lrwxrwxrwx 1 root root 0 Feb 8 17:09 exe--/USR/SBIN/SASLAUTHD
Dr-x------2 root root 0 Feb 8 17:15 FD
-R--------1 root root 0 Feb 8 17:14 limits
-rw-r--r--1 root root 0 Feb 8 17:14 loginuid
-r--r--r--1 root root 0 Feb 8 17:14 maps
-RW-------1 root root 0 Feb 8 17:14 Mem
-r--r--r--1 root root 0 Feb 8 17:14 Mounts
-R--------1 root root 0 Feb 8 17:14 mountstats
-rw-r--r--1 root root 0 Feb 8 17:14 Oom_adj
-r--r--r--1 root root 0 Feb 8 17:14 oom_score
lrwxrwxrwx 1 root root 0 Feb 8 17:14 root/
-r--r--r--1 root root 0 Feb 8 17:14 schedstat
-R--------1 root root 0 Feb 8 17:14 smaps
-r--r--r--1 root root 0 Feb 8 17:09 Stat
-r--r--r--1 root root 0 Feb 8 17:14 STATM
-r--r--r--1 root root 0 Feb 8 17:10 status
Dr-xr-xr-x 3 root root 0 Feb 8 17:15 task
-r--r--r--1 root root 0 Feb 8 17:14 Wchan
1.1. cmdline-the complete command to start the current process, but this file in the zombie process directory does not contain any information;
[Email protected] ~]# More/proc/2674/cmdline
/usr/sbin/saslauthd
1.2. cwd-a symbolic link to the running directory of the current process;
1.3, environ-the current process of the environment variable list, separated from each other by a null character (null), the variable is in uppercase letters, its value is in lowercase letters;
[Email protected] ~]# More/proc/2674/environ
Term=linuxauthd
1.4. exe-a symbolic link to the executable file (full path) that initiates the current process, and a copy of the current process can be initiated by/proc/n/exe;
1.5, fd-This is a directory, contains the current process open the file descriptor of each file (file descriptor), which is a symbolic link to the actual file;
[Email protected] ~]# LL/PROC/2674/FD
Total 0
lrwx------1 root root 8 17:17 0-/dev/null
lrwx------1 root root 8 17:17 1-/dev/null
lrwx------1 root root 8 17:17 2-/dev/null
lrwx------1 root root 8 17:17 3-socket:[7990]
lrwx------1 root root 8 17:17 4-/var/run/saslauthd/saslauthd.pid
lrwx------1 root root 8 17:17 5-socket:[7991]
lrwx------1 root root 8 17:17 6-/var/run/saslauthd/mux.accept
1.6. limits-soft limit, hard limit and snap-in for each restricted resource used by the current process; This file can only be read by the UID user who actually started the current process; (2.6.24 later kernel version supports this feature);
1.7. maps-the list of each executable file and library file that the current process is associated with in-memory mapping area and its access rights;
[Email protected] ~]# Cat/proc/2674/maps
00110000-00239000 R-xp 00000000 08:02 130647/lib/libcrypto.so.0.9.8e
00239000-0024c000 rwxp 00129000 08:02 130647/lib/libcrypto.so.0.9.8e
0024c000-00250000 Rwxp 0024c000 00:00 0
00250000-00252000 R-xp 00000000 08:02 130462/lib/libdl-2.5.so
00252000-00253000 r-xp 00001000 08:02 130462/lib/libdl-2.5.so
1.8. The memory space occupied by mem-current process is used by the system called Open, Read and Lseek, and cannot be read by the user;
1.9, root-point to the current process to run the root of the symbolic link, on UNIX and Linux systems, usually with the chroot command to run each process in a separate root directory;
1.10, stat-The current process status information, including a system formatted data columns, poor readability, usually by the PS command to use;
1.11. statm-the current process occupies memory state information, usually in "page" (pages);
1.12. status-is similar to the information provided by stat, but is more readable, as shown below, each line represents an attribute information, which is described in detail in the Man manual page of proc;
[Email protected] ~]# More/proc/2674/status
Name:saslauthd
State:s (sleeping)
sleepavg:0%
tgid:2674
pid:2674
Ppid:1
tracerpid:0
uid:0 0 0 0
gid:0 0 0 0
Fdsize:32
Groups:
vmpeak:5576 KB
vmsize:5572 KB
vmlck:0 KB
vmhwm:696 KB
vmrss:696 KB
............
1.13. The task-directory file contains information about each thread that is run by the current process, and the relevant information file for each thread is stored in a directory named by the thread number (TID), similar to the content of the content in each process directory, which is supported after kernel 2.6 version
Second, the/proc directory of common documents introduced
2.1,/PROC/APM
Advanced Power Management (APM) version information and battery-related status information, usually used by APM commands;
2.2,/proc/buddyinfo
Information file for diagnosing memory fragmentation issues;
2.3,/proc/cmdline
Relevant parameter information that is passed to the kernel at startup, which is typically delivered by a startup management tool such as LILO or GRUB;
[Email protected] ~]# More/proc/cmdline
Ro root=/dev/volgroup00/logvol00 rhgb quiet
2.4,/proc/cpuinfo
(a) A file of information about the processor;
2.5,/proc/crypto
A cryptographic algorithm used by the installed kernel on the system and a detailed list of each algorithm;
[Email protected] ~]# More/proc/crypto
name:crc32c
Driver:crc32c-generic
Module:kernel
priority:0
Type:digest
Blocksize:32
Digestsize:4
............
2.6,/proc/devices
Information for all block devices and character devices that the system has loaded, including the main device number and device group (the device type corresponding to the main device number);
[Email protected] ~]# more/proc/devices
Character Devices:
1 mem
4/dev/vc/0
4 TTY
4 TTYs
............
Block Devices:
1 RAMDisk
2 FD
8 SD
............
2.7,/proc/diskstats
A list of disk I/O statistics for each disk device, (this feature is supported in later versions of the kernel 2.5.69)
2.8,/PROC/DMA
A list of information for each ISA DMA channel that is being used and registered;
[Email protected] ~]# MORE/PROC/DMA
2:floppy
4:cascade
2.9,/proc/execdomains
A list of the execution domains currently supported by the kernel (unique "personality" of each operating system);
[Email protected] ~]# More/proc/execdomains
0-0 Linux [Kernel]
2.10,/PROC/FB
Frame buffer device list file containing the device number of the frame buffer device and related driver information;
2.11,/proc/filesystems
The file system type list file currently supported by the kernel, the file system marked as Nodev does not require block device support; When you mount a device, if you do not specify a file system type, this file will be used to determine the type of file system it requires;
[Email protected] ~]# More/proc/filesystems
Nodev Sysfs
Nodev Rootfs
Nodev proc
iso9660
Ext3
............
............
2.12,/proc/interrupts
A list of interrupt numbers associated with each IRQ on the X86 or x86_64 architecture system; Each CPU on a multiprocessor platform has its own interrupt number for each I/O device;
[Email protected] ~]# more/proc/interrupts
CPU0
0:1305421 Io-apic-edge Timer
1:61 Io-apic-edge i8042
185:1068 io-apic-level eth0
............
2.13,/proc/iomem
The mapping information of memory (RAM or ROM) in the system memory on each physical device;
[Email protected] ~]# More/proc/iomem
00000000-0009f7ff:system RAM
0009f800-0009ffff:reserved
000a0000-000bffff:video RAM Area
000c0000-000c7fff:video ROM
............
3.2.12./proc/iomem
Http://www.centos.org/docs/5/html/5.1/Deployment_Guide/s2-proc-iomem.html
This file shows your current map of the system's memory for each physical device:
00000000-0009fbff:system RAM
0009fc00-0009ffff:reserved
000a0000-000bffff:video RAM Area
000c0000-000c7fff:video ROM
000f0000-000fffff:system ROM
00100000-07ffffff:system RAM
00100000-00291ba8:kernel Code
00291ba9-002e09cb:kernel data
E0000000-e3ffffff:via Technologies, Inc. vt82c597 [Apollo VP3] E4000000-e7ffffff:pci Bus #01
E4000000-e4003fff:matrox Graphics, Inc. MGA G200 AGP
E5000000-e57fffff:matrox Graphics, Inc. MGA G200 AGP
E8000000-e8ffffff:pci Bus #01
E8000000-e8ffffff:matrox Graphics, Inc. MGA G200 AGP
Ea000000-ea00007f:digital equipment Corporation decchip 21140 [fasternet]
Ea000000-ea00007f:tulip ffff0000-ffffffff:reserved
The first column displays the memory registers used by each of the different types of memory. The second column lists the kind of memory located within those registers and displays which memory registers is used by The kernel within the system RAM or, if the network interface card has multiple Ethernet ports, the memory registers Assig Ned for each port.
/OPT/QTMARVELL/MVQT # Cat/proc/iomem
00000000-0fffffff:system RAM
0002b000-00554fff:kernel text
00556000-005a22f3:kernel data
10000000-1fffffff:system RAM
E0000000-e7ffffff:pex0 Memory
e0000000-e0003fff:0000:00:01.0
e0004000-e0004fff:0000:00:01.0
E8000000-efffffff:pex1 Memory
f1012100-f10121ff:serial8250.0
F1012100-f101211f:serial
F1090000-f10903ff:mvsdio
F1090000-f10903ff:mvsdio
f10a0000-f10a3fff:mv88fx_snd.0
F10a0000-f10a3fff:mv88fx_snd
The f10c0000-f10d0000:dovefb.0 register address maps to this
f10c0000-f10d0000:dovefb_ovly.0
/OPT/QTMARVELL/MVQT #./framebuffer
The framebuffer device was opened successfully.
Fixed Screen Info:
ID:GFX Layer 0
smem_start:0x12000000
smem_len:33554432
type:0
type_aux:0
Visual:2
Xpanstep:1
Ypanstep:1
ywrapstep:0
line_length:2560
mmio_start:0xf10c0000
mmio_len:65537
2.14,/proc/ioports
A list of input-output port range information currently in use and registered with the physical device, as shown below, the first column represents the registered I/O port range, followed by the associated device;
[Email protected] ~]# Less/proc/ioports
0000-001f:dma1
0020-0021:pic1
0040-0043:timer0
0050-0053:timer1
0060-006f:keyboard
............
2.15,/proc/kallsyms
The module management tool is used to dynamically link or bind the symbolic definitions of loadable modules, which are output by the kernel, (the kernel 2.5.71 later versions support this feature); Usually the amount of information in this file is quite large;
[Email protected] ~]# more/proc/kallsyms
c04011f0 T _stext
c04011f0 T Run_init_process
c04011f0 T Stext
............
2.16,/proc/kcore
The physical memory used by the system is stored in the ELF core file format, with a file size of the used physical memory (RAM) plus 4KB; This file is used to check the current state of the kernel data structure, so it is usually used by the GBD Debug tool. However, you cannot open this file by using the File View command;
2.17,/proc/kmsg
This file is used to hold information that is output by the kernel, usually used by programs such as/SBIN/KLOGD or/bin/dmsg, and does not attempt to open the file using the view command;
2.18,/proc/loadavg
Holds the average load on CPU and disk I/O, with the first three columns representing a load average of every 1 seconds, every 5 seconds, and every 15 seconds, similar to information about the output of the uptime command; The fourth column is a two numeric value separated by a slash that represents the number of entities (processes and threads) currently being dispatched by the kernel. The latter represents the number of kernel scheduler entities currently surviving the system; The fifth column represents the PID of the most recent process created by the kernel before this file is viewed;
[Email protected] ~]# More/proc/loadavg
0.45 0.12 0.04) 4/125 5549
[Email protected] ~]# uptime
06:00:54 up 1:06, 3 users, load average:0.45, 0.12, 0.04
2.19,/proc/locks
Holds information about files currently locked by the kernel, contains debug data inside the kernel, each lock occupies a row and has a unique number, and the second column of each row in the output information below represents the lock category currently locked, and POSIX represents the current newer type of file lock, which is generated by the LOCKF system call. Flock is a traditional UNIX file lock, generated by the flock system call; The third column is also usually made up of two types, advisory indicates that no other user is allowed to lock the file, but allows reading, mandatory indicates that no other user is allowed to access the file during the lock;
[Email protected] ~]# more/proc/locks
1:posix advisory WRITE 4904 fd:00:4325393 0 EOF
2:posix advisory WRITE 4550 fd:00:2066539 0 EOF
3:flock advisory WRITE 4497 fd:00:2066533 0 EOF
2.20,/proc/mdstat
Saves the current status information for the RAID-related disks, which are displayed as follows, without using the raid machine:
[Email protected] ~]# Less/proc/mdstat
Personalities:
Unused devices: <none>
2.21,/proc/meminfo
Information about the current state of memory utilization, etc., is often used by the free command, and can be read directly by using the File View command, which is displayed as two columns, the former is the statistic attribute, the latter is the corresponding value;
[Email protected] ~]# Less/proc/meminfo
memtotal:515492 KB
memfree:8452 KB
buffers:19724 KB
cached:376400 KB
Swapcached:4 KB
............
2.22,/proc/mounts
Prior to kernel 2.4.29, the contents of this file were all file systems currently mounted on the system, and in the kernel after 2.4.19, each process was introduced with a separate mount namespace, and this file became a point to/proc/self/ Mounts (each process itself mounts a list of all mount points in the namespace) the symbolic link of the file;/proc/self is a unique directory, which is described later in this article;
[Email protected] ~]# Ll/proc |grep Mounts
lrwxrwxrwx 1 root root 8 06:43 mounts-self/mounts
As shown below, where the first column represents the mounted device, the second column represents the mount point in the current directory tree, the 3rd represents the current file system type, the fourth column represents the Mount property (RO or RW), and the fifth and sixth columns are used to match the dump (dump) attribute in the/etc/mtab file;
[Email protected] ~]# more/proc/mounts
Rootfs/rootfs RW 0 0
/dev/root/ext3 rw,data=ordered 0 0
/dev/dev Tmpfs RW 0 0
/PROC/PROC proc RW 0 0
/sys/sys Sysfs RW 0 0
/proc/bus/usb/proc/bus/usb usbfs RW 0 0
............
2.23,/proc/modules
A list of all module names currently loaded into the kernel, which can be used by the Lsmod command or viewed directly; The first column represents the module name, the second column indicates how much memory space the module occupies, the third column indicates how many instances of this module are loaded, and the fourth column indicates which modules the module depends on. The fifth column represents the load state of this module (Live: Loaded; Loading: loading; unloading: unloading), and the sixth column represents the offset of this module in kernel memory (kernel memories);
[Email protected] ~]# More/proc/modules
AUTOFS4 24517 2-live 0xe09f7000
HIDP 23105 2-live 0xe0a06000
Rfcomm 42457 0-live 0xe0ab3000
L2cap 29505 Hidp,rfcomm, Live 0xe0aaa000
............
2.24,/proc/partitions
Information such as the master device number (major) and secondary device number (minor) for each partition of the block device, including the number of blocks (block) contained in each partition (as shown in the third column of the output below);
[Email protected] ~]# more/proc/partitions
Major Minor #blocks name
8 0 20971520 SDA
8 1 104391 sda1
8 2 6907950 Sda2
8 3 5630782 Sda3
8 4 1 SDA4
8 5 3582463 Sda5
2.25,/PROC/PCI
A list of all PCI devices and their configuration information found during kernel initialization, the configuration information is more than one PCI device related IRQ information, readability is not high, you can use the "/SBIN/LSPCI–VB" command to obtain more easily understood relevant information; After the 2.6 kernel, this file is/proc/bus/ The PCI directory and the files under it are replaced;
2.26,/proc/slabinfo
Objects that are frequently used in the kernel (such as inode, Dentry, and so on) have their own cache, the slab pool, and the/proc/slabinfo file lists the slap information about these objects; see the Slapinfo Manual in the kernel documentation for details;
[Email protected] ~]# More/proc/slabinfo
slabinfo-version:2.1
# name <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab>: Tunables < Limit> <batchcount> <sharedfactor>: Slabdata <ac
Tive_slabs> <num_slabs> <sharedavail>
Rpc_buffers 8 8 2048 2 1:tunables 8:slabdata 4 4 0
Rpc_tasks 8 192 1:tunables 8:slabdata 1 1 0
Rpc_inode_cache 6 9 448 9 1:tunables 8:slabdata 1 1 0
............
............
............
2.27,/proc/stat
Real-time tracking of various statistics since the last startup of the system, as shown below, where
The eight values after the "CPU" line represent the statistical values in 1/100 (jiffies) seconds (including the system running in user mode, low-priority user mode, operating system mode, idle mode, I/O wait mode time, etc.);
The "Intr" line gives the interrupt information, the first is the number of interrupts that have occurred since the system started, and then each number corresponds to the number of times that a particular interrupt has occurred since the system was started;
"Ctxt" gives the number of context exchanges that have occurred since the system started.
"Btime" gives the time from the system boot up to now, in seconds;
"Processes (Total_forks) The number of tasks created since the system was started;
"Procs_running": the number of tasks currently running the queue;
"Procs_blocked": the number of tasks that are currently blocked;
[Email protected] ~]# More/proc/stat
CPU 2751 26 5771 266413 2555 99 411 0
Cpu0 2751 26 5771 266413 2555 99 411 0
Intr 2810179 2780489 67 0 3 3 0 5 0 1 0 0 0 1707 0 0 9620 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5504 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 12781 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Ctxt 427300
Btime 1234084100
Processes 3491
Procs_running 1
procs_blocked 0
2.28,/proc/swaps
The Exchange partition on the current system and its spatial utilization information, if there are multiple swap partitions, the information of each swap partition is stored in a separate file in the/proc/swap directory, and the lower the priority number, the greater the likelihood of being used; The following is the output information of the author system when there is only one swap partition ;
[Root[email protected] ~]# more/proc/swaps
Filename Type Size used priority
/DEV/SDA8 Partition 642560 0-1
2.29,/proc/uptime
The elapsed time since the system was last started, as shown below, its first number indicates the system run time, the second number indicates the system idle time, the unit is seconds;
[Email protected] ~]# More/proc/uptime
3809.86 3714.13
2.30,/proc/version
The version number of the kernel that is currently running on the system, and the GCC version of the system installation is also displayed on the author's RHEL5.3, as shown below;
[Email protected] ~]# more/proc/version
Linux version 2.6.18-128.el5 ([email protected]) (GCC version 4.1.2 20080704 (Red Hat 4.1.2-44)) #1 SMP Wed Dec 17 11:42:3 9 EST 2008
2.31,/proc/vmstat
The current system virtual memory of a variety of statistical data, the amount of information may be relatively large, which is different from the system, readability is good; The following is a fragment of the output information on the author's machine; (2.6 kernel supports this file)
[Email protected] ~]# More/proc/vmstat
Nr_anon_pages 22270
nr_mapped 8542
Nr_file_pages 47706
Nr_slab 4720
Nr_page_table_pages 897
Nr_dirty 21
Nr_writeback 0
............
2.32,/proc/zoneinfo
A detailed list of memory areas (zones) with a large amount of information, listed below is an output fragment:
[Email protected] ~]# More/proc/zoneinfo
Node 0, Zone DMA
Pages Free 1208
Min 28
Low 35
High 42
Active 439
Inactive 1139
Scanned 0 (A:7 i:30)
spanned 4096
Present 4096
Nr_anon_pages 192
nr_mapped 141
Nr_file_pages 1385
Nr_slab 253
Nr_page_table_pages 2
Nr_dirty 523
Nr_writeback 0
Nr_unstable 0
Nr_bounce 0
Protection: (0, 0, 296, 296)
Pagesets
all_unreclaimable:0
Prev_priority:12
start_pfn:0
............
Three,/proc/sys catalogue detailed
Unlike the read-only attribute of other files under/proc, the administrator can modify many of the file contents in the/proc/sys subdirectory to change the operating characteristics of the kernel, and you can use the Ls-l command to see if a file is writable in advance. Write operations are typically performed in a format similar to "Echo DATA >/path/to/your/filename". It is important to note that even if the file is writable, it is generally not editable using the editor.
3.1,/proc/sys/debug sub-directory
This directory is usually an empty directory;
3.2,/proc/sys/dev sub-directory
A directory of parameter information files for special devices on the system, and information files for different devices are stored in separate subdirectories, such as/proc/sys/dev/cdrom and/proc/sys/dev/on most systems RAID (if the kernel compiles with RAID enabled) directory, it usually stores the relevant parameter information files for CDROM and raid on the system.
[Go] In-depth understanding of the/proc directory