The /proc Filesystem

/proc is one of Linux's most ingenious designs. It's a virtual filesystem — nothing in it is stored on disk. The kernel generates file contents on the fly when you read them. Every tool you use for monitoring (top, ps, free) reads from /proc.

Per-Process Information — /proc/PID/

Every running process has its own directory at /proc/PID/:

ls /proc/1/ # cmdline cwd environ exe fd/ maps mem net/ # ns/ oom_score smaps stat status task/ # The command that started the process cat /proc/1/cmdline | tr '\0' ' ' # /sbin/init splash # Current working directory ls -la /proc/1/cwd # symlink to actual directory # Open file descriptors ls -la /proc/1/fd/ # 0 -> /dev/null (stdin) # 1 -> /dev/null (stdout) # 2 -> /dev/console (stderr) # Memory map — all virtual memory regions cat /proc/1/maps # address perms offset dev inode pathname # 7f8a12000000-7f8a16000000 r--p ... /lib/x86_64/libc.so.6 # Environment variables (NUL-separated) cat /proc/1/environ | tr '\0' '\n' # Namespaces this process belongs to ls -la /proc/1/ns/

System-Wide Information

FileWhat it shows
/proc/cpuinfoCPU model, cores, flags, clock speed
/proc/meminfoRAM: total, free, available, cached, swap
/proc/loadavg1/5/15 min load average + running/total processes
/proc/uptimeSeconds since boot, seconds idle
/proc/statCPU time breakdown, context switches, interrupts, boot time
/proc/diskstatsPer-disk I/O counters (reads, writes, time spent)
/proc/net/devPer-interface network stats
/proc/interruptsPer-CPU interrupt counts by IRQ

/proc/sys — Kernel Tuning

How do you tune kernel parameters? By reading and writing files in /proc/sys/. The sysctl command is just a friendly interface to these files.
# Read a kernel parameter cat /proc/sys/net/ipv4/ip_forward # 0 or 1 # Change it (takes effect immediately, not persistent) echo 1 > /proc/sys/net/ipv4/ip_forward # Same thing with sysctl sysctl net.ipv4.ip_forward # read sysctl -w net.ipv4.ip_forward=1 # write # Make persistent across reboots echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf sysctl -p # apply sysctl.conf

Key tunable areas: /proc/sys/vm/ (memory behavior), /proc/sys/net/ (networking), /proc/sys/kernel/ (scheduler, core dumps, panic behavior).

Frequently Asked Questions

What will I learn here?

This page covers the core concepts and techniques you need to understand the topic and progress confidently to the next lesson.

How should I use this page?

Start with the overview, then follow the section links to deepen your understanding. Use the table of contents on the right to jump to specific sections.

What should I read next?

Use the navigation below to continue to the next lesson or explore related topics.