timerring

Further Understanding of Proc

February 1, 2025 · 3 min read · Page View:
Tutorial
Linux

Generated by DALL-E 3: The pixel art depicts the linux symbol penguin is holding a proc card above its head.

If you have any questions, feel free to comment below.

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

Related readings


<< prev | The Iftop Continue strolling

If you find this blog useful and want to support my blog, need my skill for something, or have a coffee chat with me, feel free to: