Go to proc file

Source: Internet
Author: User
Tags snmp syslog

/proc is a pseudo-file system that is used as an interface for kernel data structures, not just to explain that most of the files in/dev/kmem./proc are read-only, but you can also change kernel variables by writing some files.

The following is a rough introduction to the entire/proc directory.

[number]
In the/proc directory, each running process has a subdirectory named after the process ID, which includes the following directories and pseudo-Files: [number]/cmdline
The file holds the full command line for the process. If the process has been swapped out of memory, or if the process is dead, then nothing is in the file, and the read operation on the file will return 0 characters. The file ends with a null character, not a line break.
[number]/CWD
A symbolic connection that points to the current working directory of the process. For example, to find the CWD for process 20, you can:
CD/PROC/20/CWD; /bin/pwd
Note that the PWD command is usually built into the shell and may not work well in such a situation (Casper Note: pwd can only show/PROC/20/CWD, if you want to know its working directory, directly ls-al/proc/20 not good).
[number]/environ
The file holds the environment variables for the process, separated by a null character, and possibly a null character at the end. Therefore, if you want to output the environment variables for process 1, you should:
(Cat/proc/1/environ; echo) | TR "; \000"; "; \ n";
(For the reasons why you want to do this, see Lilo (8).)
[number]/exe
is also a symbolic connection, pointing to the binary code being executed. In Linux 2.0 or earlier, the Readlink (2) of EXE special files returns a string in the following format: [Device number]: node number for example, [0301]:1502 is the 1502 node of a device, the device's main device number is 03 (such as the IDE , MFM, etc.), from the device number 01 (first partition of the first drive). Under Linux 2.2, Readlink (2) gives the actual path name of the command. In addition, the symbolic connection can be referenced normally (attempting to open an EXE file will actually open an executable file). You can even type/proc/[number]/exe to run a copy of the [number] process. The Find (1) command with the-inum option can locate the file.
[number]/fd
Each file opened by the process has a symbolic connection to that subdirectory, named after the file descriptor, which is actually a symbolic connection to the real file (as with the EXE record). For example, 0 is the standard input, 1 is the standard output, 2 is the standard error, and so on. The program may sometimes want to read a file but do not want the standard input, or want to write to a file but do not want to send the output to the standard output, it is very effective to cheat (assuming-i is the input file's flag, and-O is the output file's flag):
Foobar-i/proc/self/fd/0-O/PROC/SELF/FD/1 ...
This is a filter that works. Please note that this method cannot be used to search the file because the files in the FD directory are not searchable. In UNIX-like systems,/proc/self/fd/n is basically the same as/dev/fd/n. In fact, most Linux Makedev scripts connect the/DEV/FD symbol to the [....] On the/PROC/SELF/FD.
[number]/maps
The file contains the current image memory area and their access permission. The format is as follows:
Address perms offset Dev inode

00000000-0002f000 r-x--00000400 03:03 1401 (read-only code snippet)

0002f000-00032000 rwx-p 0002f400 03:03 1401 (writable data segment)

00032000-0005b000 Rwx-p 00000000 00:00 0 (heap)

60000000-60098000 rwx-p 00000400 03:03 215 (Library read-only code snippet)

60098000-600c7000 Rwx-p 00000000 00:00 0

bfffa000-c0000000 Rwx-p 00000000 00:00 0

Addresses are the address spaces that the process occupies, and perms is the permission set:
R = Read
w = Write
x = Execute
s = Shared
p = Private (copy on write)
Offset is a file or something, Dev is the device number (main device number: from the device number), and the Inode is the node number of the device. 0 indicates that no node corresponds to memory, just like the case of BSS.
Under Linux 2.2, a domain is also added to the available path names, such as/bin/busybox.
Mem
This file is not a mem (1:1) device, although they have the same device number. The/DEV/MEM device is the physical memory that is used before any address conversion, and the mem file here is the memory of the process that accesses it. Currently, this mem is not mmap (2) (memory mapped), and may have to wait until the kernel adds a generic mmap (2) to be implemented. (Maybe it all happened when you read the manual page)

mmap
Mmap (2) Do maps mapping directory, is and EXE, fd/* and other similar symbolic connection. Please note that maps contains more information than/proc/*/mmap, so mmap should be discarded. "; 0"; Usually refers to libc.so.4. In Linux kernel 1.1.40,/proc/*/mmap was canceled. (now it's really obsolete!)

Root
Depending on the system call Chroot (2), UNIX and Linux allow each process to have its own file system root directory. Set by the Chroot (2) system call. Root points to the root of the filesystem, the nature is like EXE, fd/* and so on. Stat
Process state information, which iscommand PS (1) to use.
Now the fields in the file, and their scanf (3)The format specifier, in order, is divided into the following:
PID%d process identity.
CommThe file name of the%s executable file, including the path. Whether the file is visible depends on whether the file has been swapped out of memory.
State%c "; Rsdzt "; One, R is running, S is sleep in an interruptible ready state, D is sleep in an interruptible wait or swap state, Z is zombie, T is tracked or stopped (due to a signal being received).
Ppid%d parent process PID.
PgrpThe process group ID of the%d process.
SessionThe session ID of the%d process.
TTYThe terminal used by the%d process.
Tpgid%d the process group ID of the process that currently owns the terminal to which the process is connected.
Flags%u process flag. At present, each logo has a number of degrees, so the output does not include this bit. Crt0.s checking mathematical simulations This could be a bug, because not every process is compiled with C. The number of degrees should be 4 decimal, and the tracking bit should be 10 decimal.
MinfltThe number of small errors (minor faults) caused by the%u process, such that small errors (minor faults) do not have to reload a memory page from disk.
CminfltThe number of minor errors (minor faults) caused by the%u process and its child processes.
MajfltThe number of large errors (major faults) caused by the%u process, such a large error (major faults) needs to be re-loaded into the memory page.
CmajfltThe number of large errors (major faults) caused by the%u process and its child processes.
Utime%d processes are dispatched into the user state (in Jiffy, 1 jiffy=1/100 seconds, and different hardware systems are slightly different).
stimeThe time that the%d process was dispatched into the kernel state, in Jiffy.
CutimeThe time that the%d process and its child processes are dispatched into the user state, in Jiffy units.
CstimeThe time that the%d process and its child processes are dispatched into the kernel state, in Jiffy.
counter%d if the process is not currently running, it is the maximum time that the process can currently have at the next time slice, in Jiffy. If the process is currently running, it is the number of Jiffy left in the current time slice.
PriorityThe%d standard priority number only adds 15, and the value is always positive in the kernel.
Timeout%u current to the next interval of the process, in Jiffy.
Itrealvalue%u due to the timing interval caused by the delay of the next SIGALRM send process, in jiffy units.
StartTimeThe start time of the%d process since the system started, in Jiffy.
vsize%u virtual memory size.
RSS%u resident Set Size (resident size): The actual memory size occupied by the process, in pages, minus 3 for ease of administration. RSS only includes the body, data, and stack space, but does not include the need to load memory or has been swapped out.
RlimThe RSS limit for the current process, in bytes, typically 2,147,483,647.
Startcode%u body part address lower limit.
Endcode%u body part address upper limit.
Startstack%u stack start address.
KstkespThe current value of%u ESP (32-bit stack pointer), and is consistent on the kernel stack page of the process.
KstkeipThe current value of%u EIP (32-bit instruction pointer).
Signal%d bitmap (usually 0) of the signal to be processed.
blocked%d bitmap of blocked signals (usually 0, 2 for the shell).
Sigignore%d bitmap of the ignored signal.
Sigcatch%d bitmap of the captured signal.
WchanThe channel in which the%u process waits, which is actually the address of a system call. If you need text format, you can also find it in the list of names. (If you have the latest version of/etc/psdatabase, you can ps-lThe results of the Wchan field see)
CpuinfoA list of CPU and architecture dependency entries is saved. For different system architectures there are different lists, the two are CPU and bogomips, the CPU may be the CPU currently in use, and bogomips is a system constant that is computed when the kernel is initialized.
Devices
A list of main device numbers and device groups, in text format. The Makedev script uses this file to maintain kernel consistency.
DMA
A list that indicates what is being used ISADMA (direct memory access) channel.
filesystems
Listed in text format is compiled into theThe file system of the kernel. Mount (1) relies on this file to traverse different file systems when no file system is specified for Mount (1).
Interrupts
This file records the number of interrupts per IRQ (at least on the i386 system) in ASCII format.
Ioports
This file lists the registered I/O port ranges that are currently in use.
Kcore
The pseudo-file gives the physical memory image of the system in the core file format, then uses the unloaded kernel (/usr/src/linux/tools/zsystem), and we can use GDB to explore any data structure of the current kernel.
The total length of the file is the size of the physical memory (RAM) plus 4KB.
kmsg
Can replace the system with this filecall Syslog (2) to log the kernel information. However, it requires the ultimate user right to read the file, and only one process can read the file at a time, so if a syslog (2) system call function is used to log the kernel information, the process is running. Other processes can no longer read the pseudo-file.
The contents of the file can be used DMESG (8)To see.
ksyms
This file holds the symbolic definition of the kernel output, and modules (X) uses the file to dynamicallyTo connect and bundle the Loadable modules.
Loadavg
The average load number gives the number of tasks in the running queue for the last 1, 5, 15 minutes, andUptime (1) etc.The result of the command is the same.
Locks
This file shows the current file lock.
malloc
This file will be available only if CONFIGDEBUGMALLOC is defined at compile time.
Meminfo
Free (1) uses this file to give the total idle memory and used memory (including physical memory and swap memory) of the system, and the shared memory and buffers used by the kernel.
The file and free (1)The same type, but in bytes instead of KB.
Modules
Lists the modules that the system has loaded, the text format.
Net
This subdirectory includes multiple ASCII-formatted network artifacts, which describe some of the network layer scenarios. can use cat to view these files, but the standardnetstat(8) The command group gives the information of these files more clearly.
ARP
The file saves the kernel ARP table in ASCII format for address resolution, including static and dynamic ARP data. The file format is as follows: IP address HW type Flags HW Address
10.11.100.129 0x1 0x6 00:20:8a:00:0c:5a
10.11.100.5 0x1 0x2 00:c0:ea:00:00:4e
44.131.10.6 0x3 0x2 gw4pts
where ' IP address ' is the IPv4 of the machine; ' HW type ' is the hardware type of the address, followed by RFC 826; Flags are internal flags of the ARP structure and are defined in/usr/include/linux/if_arp.h; The ' HW address ' is the physical layer mapping (if known) of the IP addresses.
Dev
The pseudo-file contains network device status information, gives the number of packets sent and received, the number of errors and conflicts, and some other basic statistics.ifconfig (8)This file is used to report the status of network devices. The file format is as follows: inter-| receive| Transmit face|packets errs drop FIFO frame|packets errs drop FIFO colls carrier
lo:0 0 0 0 0 2353 0 0 0 0 0
eth0:644324 1 0 0 1 563770 0 0 0 581 0
IPX
No information.
Ipx_route
No information.
Rarp
The file has a andARP is the same format that contains the current reverse address mapping data. RARP (8)Use this data for reverse address lookup services. The file exists only if the RARP is set into the kernel.
Raw
The file holds the RAW socket table, and most of the information is not useful except for debugging. Includes local address and protocol number pairs; "St" is the internal state of the socket; Tx_queue and Rx_queue are the input and output data queue of kernel memory usage; RAW does not use "tr", "Tm->when" and "rexmits"; The UID is the valid UID of the socket creator.
Route
no information, but looks similar to route (8)
SNMP
The file stores the data information required for IP, ICMP, TCP, and UDP Management in ASCII format, based on the SNMP protocol. The TCP MIB (TCP management database) is not yet complete and may be completed in the 1.2.0 kernel. TCP
The file holds the TCP socket table, and most of the information is not useful except for debugging. "SL" indicates the core hash slot number of the socket; The "Local address" includes the location and port number; "Remote Address" includes a remote location and port number (if connected); ' St ' is the internal state of the socket; ' Tx_queue ' and ' rx_queue ' are input and output data queues for kernel memory usage; "TR", "Tm->when" and "rexmits" Save the internal information of the kernel socket declaration, only for debugging; The UID is the valid UID of the socket creator. UDP
The file holds the UDP socket table, and most of the information is not useful except for debugging. "SL" indicates the core hash slot number of the socket; The "Local address" includes the location and port number; "Remote Address" includes a remote location and port number (if connected); "St" is the internal state of the socket; "Tx_queue" and "rx_queue" are the input and output data queues for kernel memory usage; UDP does not use "tr", "Tm->when" and "rexmits"; The UID is the valid UID of the socket creator. The format is as follows: SL local_address rem_address St Tx_queue rx_queue tr rexmits tm->when UID
1:01642c89:0201 0c642c89:03ff 00000000:00000001 01:000071ba 00000000 0
1:00000000:0801 00000000:0000 0A 00000000:00000000 00:00000000 6f000100 0
1:00000000:0201 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 Unix
Lists the UNIX domain sockets and their status for the current system, in the following format: Num refcount Protocol Flags Type St Path
0:00000002 00000000 00000000) 0001 03
1:00000001 00000000 00010000 0001 01/dev/printer
At present always 0; ' Flags ' is the kernel flag that indicates the state of the socket; ' Type ' is currently always 1 (Unix domain datagram sockets are not supported in the kernel); ' St ' is the socket internal state; Path of the ' path ' socket bundle, if any. PCI
This file lists all the PCI devices and their settings that were found when the kernel was initialized. SCSI
The directory includes SCSI middle-tier pseudo-files and a variety of SCSI underlying drive subdirectories, one for each SCSI host in the system, and a file corresponding to the subdirectory, showing the status of some SCSI IO subsystems. These files are in ASCII format and can be read by cat.
You can also reset the subsystem by writing some of these files, switching some functions.
SCSIThis file lists all of the SCSI devices that the kernel controls, similar to what they saw when the system was started. Currently SCSI only supports the Singledevice command, which allows root to add a hot-swappable (hotplugged) device to a list of known devices.
Command echo ' SCSI singledevice 1 0 5 0 ' >/PROC/SCSI/SCSI make host SCSI1 scan SCSI channel 0 To see if the device exists on ID 5 LUN 0, if there is a device at that address, or the location Invalid address, an error is returned.
drivername
Currently drivernameCan include: ncr53c7xx, aha152x, aha1542, aha1740, Aic7xxx, BusLogic, EATA_DMA, Eata_pio, Fdomain, in2000, PAS16, QLogic, Scsi_deb UG, Seagate, T128, u15-24f, Ultrastore or wd7000. These directories show drivers that have at least one SCSI HBA registered. For each registered host, each directory contains a file and the corresponding host file is named after the number assigned to host at the time of initialization.
These files give the driver and device settings, statistics, and so on.
It is possible to do different things by writing these files to a different host. For example, root can use the latency and Nolatency commands to turn on or off the measure delay code on the EATA_DMA drive, and also to control the bus lock operation that the unlock drive simulates with the lockup and Scsi_debug commands. Self
When a process accesses the/proc directory, the directory points to the directory under/proc named after the process ID.
Stat
Kernel and system statistics.
CPU 3357 0 4313 1362393
The system is consumed in user mode, low priority user mode (NICE), system mode, and idle task time in Jiffy units. The last value should be 100 times times the second value of the uptime pseudo-file.
Disk 0 0 0 0
The four disk records are not currently being implemented, and I even think that it should not be implemented because the kernel stats on other machines typically depend on the conversion rate and the number of I/Os per second, which allows only one domain per drive.
page 5741 1808
The number of pages swapped in and out of the system (from disk).
Swap 1 0
The number of pages of the swap page and the number of swapped pages that were fetched.
intr 1462898
The number of interrupts received since the system was started.
ctxt 115315
The number of process environment transitions made by the system.
btime 769041601
The total elapsed time of the system since January 1, 1970, in seconds.
SYS
The directory begins in the kernel of 1.3.57 and contains some files and subdirectories that correspond to kernel variables. You can read these variables, and some can also pass procModify, or use system invoke sysctl(2) modify.Currently, the directory has the following three subdirectories: Kernel;, ; Net;, ; VMSEach includes some files and subdirectories.
Kernel
The directory includes the following files: DomainName;, ; File-max;, ; File-nr;, ; hostname;, ; Inode-max;, ; Inode-nr;, ; Osrelease;, ; OSType;, ; Panic;, ; Real-root-dev;, ; Securelevel;, ; version, the file name will be able to clearly know the functions of the files.
Read-only files File-nrGives the number of files currently open.
File File-maxProvides the maximum number of open files allowed by the system. If 1024 is not big enough, you can
echo 4096 >/proc/sys/kernel/file-max
Similarly, the file Inode-nrand documents Inode-maxIndicates the current number of inode and the maximum number of inode.
File OSType;, ; Osrelease;, ; versionis actually /proc/versionSubstring of the string.
File PanicCan be on the kernel variable Panic_timeoutFor read/write access. If the value is zero, the kernel enters the (dead) loop when panic. If nonzero, the value indicates the time, in seconds, that the kernel will automatically restart.
File SecurelevelIt doesn't seem to make sense at the moment-root omnipotent.
Uptime
The file contains two numbers: System uptime and total idle time, in seconds.
version
Indicates which version of the kernel is currently running, for example: Linux version 1.0.9 (
[[Email protected]Phaze] [Email protected] [/Email
) #1 Sat may 01:51:54 EDT 1994

Go to proc file

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.