/proc - Virtual Filesystem (in RAM), System & Process Info

The /proc directory is a special virtual filesystem in Linux that provides a window into the kernel's internal data structures. It doesn't contain real files on disk - instead, it's dynamically generated by the kernel to expose system and process information.

Key characteristics

Virtual filesystem: The files in /proc exist only in memory. When you read them, the kernel generates the content on-the-fly. This means they typically show a size of 0 bytes, but still contain data when read.

Process information: Each running process has a subdirectory named by its PID (Process ID). For example, /proc/1234/ contains information about process 1234, including:

  • cmdline - the command that started the process
  • status - detailed process state information
  • maps - memory mappings
  • fd/ - symbolic links to open file descriptors
  • environ - environment variables

System information: The root /proc directory contains files about the overall system:

  • /proc/cpuinfo - CPU details
  • /proc/meminfo - memory usage statistics
  • /proc/version - kernel version
  • /proc/uptime - how long the system has been running
  • /proc/loadavg - system load averages
  • /proc/mounts - currently mounted filesystems
  • /proc/net/ - networking information

Kernel tuning: The /proc/sys/ subdirectory allows you to view and modify kernel parameters at runtime. For example, /proc/sys/vm/swappiness controls how aggressively the kernel swaps memory to disk.

Many system utilities like ps, top, and free get their information by reading from /proc. It's an essential interface between user space and the kernel.


Backlinks