Proc directory under the Linux system

Source: Internet
Author: User
Tags readable

1, proc-a virtual file system

The/proc file system is a mechanism used by kernel and kernel modules to send information to processes (so called/proc). This pseudo file system allows you to interact with the internal data structure of the kernel, get useful information about the process, and change the settings (by changing the kernel parameters) in the run (on the fly). Unlike other file systems,/proc exists in memory, not on the hard disk.

2,/proc is controlled by the kernel and does not have a device that hosts/proc. Because/proc primarily stores state information controlled by the kernel, the logical location of most of this information resides in kernel-controlled memory. A ' ls-l ' for/proc can see that most files are 0 bytes large, but when you look at these files, you can actually see some information. How is that possible? This is because the/proc file system registers itself with the virtual file system layer (VFS) Like other regular file systems. However, until the VFS invokes it and requests the i-node of the file and directory, the/proc file system establishes the corresponding files and directories based on the information in the kernel.  
Note (the inode is a data structure in the UNIX operating system, which is essentially a struct that contains some important information related to the files in the file system.) When you create a file system in UNIX, a large number of inode is created at the same time

3
/proc files can be used to access information about the state of the kernel, the properties of the computer, the state of the running process, and so on. Most files and directories in/proc provide the latest information about the physical environment of the system. Although the files in/proc are virtual, they can still be viewed using any file editor or a program like ' more ' or ' less ' or ' cat '. proc file system can be used to gather useful information about the system and the running kernel. Here are some important files:


/PROC/CPUINFO-CPU information (model, family, cache size, etc.)/proc/meminfo-Information on physical memory, swap space, etc./proc/mounts-list of loaded file systems/proc/devices-List of available devices/ Proc/filesystems-Supported file system/proc/modules-loaded module/proc/version-kernel version/proc/cmdline-kernel command line parameters entered at system startup

4. Information about the running process
the/proc file system can be used to obtain information about a running process. There are some numbered subdirectories in the/proc. Each numbered directory corresponds to a process ID (PID). In this way, each running process/proc has a directory named after it's PID. These subdirectories contain files that can provide important details about the state of the process and the environment. Let's try to find a running process. In 1 10 11 is actually the process ID number ~ ~ is process information of process ID 1


5. Interacting with the kernel via/proc
Most of the/proc files discussed above are read-only. In fact, the/proc file system provides a mechanism for interacting with the kernel through files that can be read and written in/proc. Writing these files can change the state of the kernel, so make careful changes to the files. The/proc/sys directory, which stores all readable and writable files, can be used to change kernel behavior.
/proc/sys/kernel-This directory contains information about the anti-generic kernel behavior. /proc/sys/kernel/{domainname, hostname} holds the domain name and hostname of the machine/network. These files can be used to modify these names.

cmdline-the full command to start the current process, but this file in the zombie process directory contains no information, cwd-a symbolic link to the current process run directory, environ-the current process's list of environment variables, separated by a null character (null), and the variable is in uppercase letters, The value is in lowercase letters; exe-a symbolic link to the executable file (full path) that starts the current process, and/proc/n/exe can start a copy of the current process; fd-This is a directory that contains the file descriptor for each file opened by the current process Descriptor), these file descriptors are a symbolic link to the actual file, limits-the 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; maps- A list of each executable file and library file that the current process is associated with in-memory mapped areas and their access rights; mem-the memory space occupied by the current process is used by system calls such as open, read and Lseek, and cannot be read by the user; root- A symbolic link that points to the root of the current process run; on UNIX and Linux systems, the chroot command is used to run each process in a separate root directory, stat-the status information of the current process, contains a system formatted data column, poor readability, usually used by the PS command; statm- The current process consumes the state information of memory, usually as a "page", status-is similar to the information provided by stat, but is more readable, as shown below, each line represents a property information, which is described in detail in the Proc man manual page task-catalog file, Contains information about each thread that is run by the current process, and the relevant information files for each thread are stored in a directory named by the thread number (TID), similar to the contents of each process directory;

See http://blog.chinaunix.net/uid-23046336-id-3255640.html for details

Proc directory under the Linux system

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.