Linux system proc directory process information detailed

  
 

The Proc File System is a real-time, resident memory file system that keeps track of how processes are running on your machine and the state of your system. The /proc filesystem is resident virtual memory and maintains dynamic data for the operating system
. Most of the /proc file system information is updated in real time to match the state of the current operating system
. The contents of the /proc file system can be read by anyone with appropriate permissions. However, specific parts of the /proc filesystem can only be read by the owner and root user of the process. The contents of the /proc filesystem get data from a specific /proc directory and display them. They have many uses. The following is an example of a PROC file system. It can be seen that there are many numbers in the proc file system. Other information is relatively easy to understand. I will not introduce it here. This article mainly analyzes the digital information in the proc directory.

#cd proc

#ls1 4 9 diskstats iomem meminfo self uptime10 5 97 driver ioports misc slabinfo version114 6 buddyinfo execdomains irq mounts stat vmstat126 7 bus filesystems kcore mtd swaps zoneinfo128 8 cmdline fs kmsg net Sys2 85 cpuinfo ide loadavg partitions sysvipc3 88 devices interrupts locks pci tty The digital directories listed above that you see represent processes, which are running on the machine when we take a snapshot of the /proc filesystem. Let's take a look at the contents of a process directory: # ll 126total 0-r--r--r-- 1 root root 0 Jan 1 00:08 cmdlinelrwxrwxrwx 1 root root 0 Jan 1 00:09 cwd -> /proc-r -------- 1 root root 0 Jan 1 00:09 environlrwxrwxrwx 1 root root 0 Jan 1 00:09 exe -> /bin/bashdr-x------ 2 root root 0 Jan 1 00 :00 fd-r--r--r-- 1 root root 0 Jan 1 00:09 maps-rw------- 1 root root 0 Jan 1 00:09 mem-r--r--r -- 1 root root 0 Jan 1 00:00 mounts-rw-r--r-- 1 root root 0 Jan 1 00:09 oom_adj-r--r--r-- 1 root root 0 Jan 1 00:09 Oom_scorelrwxrwxrwx 1 root root 0 Jan 1 00:09 root -> /-r--r--r-- 1 root root 0 Jan 1 00:09 smaps-r--r--r-- 1 root root 0 Jan 1 00:08 stat-r--r--r-- 1 root root 0 Jan 1 00:09 statm-r--r--r-- 1 root root 0 Jan 1 00:08 statusdr-xr-xr- x 3 root root 0 Jan 1 00:09 task

Look at the first line of the output above.

-r--r--r-- 1 root root 0 Jan 1 00:08 cmdline

"cmdline" This file contains the entire command line used to generate the process. The content of this file is the command line arguments including all the parameters passed to start the process. All the information contained in this file is the command and the various startup parameters, without any formatting and any spaces.

lrwxrwxrwx 1 root root 0 Jan 1 00:09 cwd -> /proc

"cwd", as we saw above, this is a symbolic link that points to the process Current working directory.

-r-------- 1 root root 0 Jan 1 00:09 environ

"environ"includes all environment variables defined in VARIABL=value for this process . Just like "cmdline", the commands contained in the file and the information for each parameter do not have any formatting or spaces.

lrwxrwxrwx 1 root root 0 Jan 1 00:09 exe -> /bin/ver

"exe", this is a symbolic link to the executable that starts the current process.

dr-x------ 2 root root 0 Jan 1 00:00 fd

"fd", this directory contains the file descriptors opened by the specified process, if one If there are too many file descriptors opened by the process, it will cause the file to fail to open. By checking this directory, you can find the reason for the failure to open the file.

-r--r--r-- 1 root root 0 Jan 1 00:09 maps

"maps", when you type the contents of this named pipe, you can see The address space portion of the process, currently mapped to a file. This part, from left to right, is: the address space associated with this mapping, the permissions associated with this mapping, the offset from the beginning of the file (ie where the mapping begins), the device where the mapping file is located, the inode of the file. The number is finally the file name itself.

"root", this is a symbolic link to the /proc directory of this process.

-r--r--r-- 1 root root 0 Jan 1 00:08 status

"status", this file gives you information about the process name, its current State, sleep or awake, its PID, UID, PPID and a lot of other basic information. This information can be seen in a simpler and structured syntax by using tools such as "ps" and "top".

Copyright © Windows knowledge All Rights Reserved