Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

proc

procfs is a virtual file system provided by the Linux kernel to applications. It contains a large amount of information for process and system management. Here, I introduce the procfs files I have worked with.

procfs files

NameDescription
cmdlineKernel boot parameters. Can be modified in /boot/grub/grub.cfg.
config.gzThe kernel config file, which needs to be decompressed before use.
cpuinfoInformation about the current system’s CPUs.
interruptsInfo about interrupts, such as user, CPU, and count. It's hard to read directly; consider using python-linux-procfs to parse /proc/interrupts.
kallsymsAll symbols and addresses in the kernel. Requires root privileges to access addresses.
loadavgSystem load average over 1, 5, and 15 minutes. Load above 1 indicates high system usage.
meminfoCurrent memory information, including total, free, and page size breakdowns.
sysrq-triggerControls sysrq actions like dumping memory, rebooting, etc. It's triggered by magic sysrq keys or by writing to this file.
uptimeSystem uptime.
sysKernel parameter configuration directory. Files under /proc/sys are controlled by sysctl. Note: /sys is for driver management.
net/bondingCheck current primary slave in a bonding interface.

pid files

NameDescription
attrOnly accessible with security module support (e.g., SELinux).
cgroupShows the cgroup the current process belongs to.
cmdlineCommand line used to start the process.
cwdSymbolic link to the current working directory of the process.
environAll environment variables for the current process.
execSymbolic link to the binary the process is executing.
fdA directory listing all file descriptors opened by the process.
limitsProcess limits, such as max number of open files.
ioI/O stats including read/write bytes and network usage. Note: eio field may show strange values after process termination.
mapsMemory map of the process's address space.
oom_scoreA value used by the OOM killer to prioritize which process to kill. The higher the score, the more likely it is to be killed.
statRaw process metadata, including status, ownership, priority, last CPU used, CPU jiffies, etc.
statusHuman-readable version of stat.
wchanThe function name in the kernel where the process is blocked.

Tools: You can use libraries like psutil or python-linux-procfs to parse and work with the procfs.