Further Understanding of Proc

举报
timerring 发表于 2025/02/19 12:39:16 2025/02/19
81 0 0
【摘要】 This article is also posted on my blog, feel free to check the latest revision: Further Understanding of ProcThe /proc in Linux is a kind of Pseudo file system (also known as Virtual File System), ...

This article is also posted on my blog, feel free to check the latest revision: Further Understanding of Proc

The /proc in Linux is a kind of Pseudo file system (also known as Virtual File System), what it saves is a series of special files that store the current running state of the kernel, and the user can check the hardware info and the runnning processes via the files, even adjust some files to change the state of running kernel. The files in /proc will be refresh in RAM, so the files’ size is 0 bytes.

You can check the official docs here.

The number Directory

There are many dirs named the number, which indicate the pid of running process.

  • cmdline — The command line of the process.
  • environ — The environment variables of the process.
  • fd — The file descriptors of the process.
  • maps — The memory maps of the process.
  • mem — The memory usage of the process.
  • root — The root directory of the process.
  • status — The status of the process. Highly readable.
  • stat — The detailed status of the process. Usually used by ps command.
  • task — The task of the process, which saves the tid of every thread whose form is similar to pid.

/proc/sys

This directory is used to change the state of the kernel. You can write the file to change the state of the kernel.

Common files

/proc/apm

Advanced Power Management (APM) version information and battery - related status information, typically used by the apm command.

/proc/buddyinfo

The information about the free memory blocks.

/proc/cmdline

This file shows the parameters passed to the kernel at the time it is started.

/proc/cpuinfo

The information about the CPU.

/proc/crypto

This file lists all installed cryptographic ciphers used by the Linux kernel.

/proc/devices

This file displays the various character and block devices currently configured (not including devices whose modules are not loaded).

/proc/iomem

This file shows the memory map of the system.

/proc/ioports

This file shows the I/O ports that the system uses.

/proc/loadavg

This file shows the load average of the system. The same as the output of uptime command.

cat /proc/loadavg
# 2.79 2.99 3.03 5/349 3582467

The first three columns measure CPU and IO utilization of the last 1, 5, and 15 minute periods. The fourth column shows the number of currently running processes and the total number of processes. The last column displays the last process ID used.

/proc/meminfo

This file shows the information about the memory, which is often used by the free command.

/proc/stat

Some of the more commonly used statistics include:

  • cpu — Measures the number of jiffies (1/100 of a second for x86 systems) that the system has been in user mode, user mode with low priority (nice), system mode, idle task, I/O wait, IRQ (hardirq), and softirq respectively. The IRQ (hardirq) is the direct response to a hardware event. The IRQ takes minimal work for queuing the “heavy” work up for the softirq to execute. The softirq runs at a lower priority than the IRQ and therefore may be interrupted more frequently. The total for all CPUs is given at the top, while each individual CPU is listed below with its own statistics. The following example is a 4-way Intel Pentium Xeon configuration with multi-threading enabled, therefore showing four physical processors and four virtual processors totaling eight processors.
  • page — The number of memory pages the system has written in and out to disk.
  • swap — The number of swap pages the system has brought in and out.
  • intr — The number of interrupts the system has experienced.
  • btime — The boot time, measured in the number of seconds since January 1, 1970, otherwise known as the epoch.
  • ctxt — The number of context switches.
  • processes — The total number of processes.
  • procs_running — The number of processes in the run queue.
  • procs_blocked — The number of processes in the wait queue.
  • softirq — The number of softirqs the system has experienced.

/proc/swaps

This file shows the information about the swap.

/proc/uptime

The first value represents the total number of seconds the system has been up. The second value is the sum of how much time each core has spent idle, in seconds. Consequently, the second value may be greater than the overall system uptime on systems with multiple cores.

/proc/version

This file shows the version of the kernel. Also the gcc version.

Other files

  • /proc/diskstats
  • /proc/dma
  • /proc/execdomains
  • /proc/fb
  • /proc/interrupts
  • /proc/kallsyms
  • /proc/kcore
  • /proc/kmsg
  • /proc/locks
  • /proc/mdstat
  • /proc/mounts
  • /proc/modules
  • /proc/partitions
  • /proc/pci
  • /proc/slabinfo
  • /proc/vmstat
  • /proc/zoneinfo
【版权声明】本文为华为云社区用户原创内容,未经允许不得转载,如需转载请自行联系原作者进行授权。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

作者其他文章

评论(0

抱歉,系统识别当前为高风险访问,暂不支持该操作

    全部回复

    上滑加载中

    设置昵称

    在此一键设置昵称,即可参与社区互动!

    *长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

    *长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。