The /proc Filesystem — In Depth
/proc is a virtual filesystem generated on the fly by the kernel. Nothing in it exists on disk. It gives you a live window into CPU info, memory state, process details, network state, and the kernel's own runtime configuration.
Series: Learning Linux from Scratch
- 1. Learning Linux from Scratch — After a Full IT Apprenticeship
- 2. What is Linux?
- 3. The Filesystem
- 4. Users and Permissions
- 5. Installing and Managing Software
- 6. Text Editors
- 7. Shell Scripting Basics
- 8. Process Management
- 9. Networking Fundamentals
- 10. SSH
- 11. systemd and Services
- 12. Disk Management
- 13. Users and Groups — In Depth
- 14. Cron and Scheduled Tasks
- 15. Firewall — iptables and ufw
- 16. Environment Variables and the Shell
- 17. Log Management
- 18. Kernel Module Management
- 19. The /proc Filesystem — In Depth
- 20. The /sys Filesystem and udev
- 21. Kernel Parameters and sysctl
- 22. Compiling and Installing a Custom Kernel
/proc is a virtual filesystem. Nothing in it exists on disk. It is generated on the fly by the kernel and gives you a live window into exactly what the kernel knows about the system — hardware, processes, memory, network state, and its own configuration.
Every file you read from /proc is the kernel answering a question in real time.
System information
CPU
cat /proc/cpuinfoOne block per logical CPU. Key fields:
processor— logical CPU index (0-based)model name— CPU model stringcpu MHz— current clock speedcache size— L2 cachesiblings— logical CPUs sharing the physical packagecpu cores— physical cores per packageflags— CPU feature flags (sse4_2, avx2, vmx for virtualisation, etc.)
Count logical CPUs:
grep -c "^processor" /proc/cpuinfoCheck for virtualisation support:
grep -E "vmx|svm" /proc/cpuinfovmx is Intel VT-x. svm is AMD-V. Required for running KVM virtual machines.
Memory
cat /proc/meminfoKey fields:
| Field | Meaning |
|---|---|
MemTotal | Total physical RAM |
MemFree | Completely unused RAM |
MemAvailable | RAM available for new processes (more useful than MemFree) |
Buffers | RAM used for kernel buffers |
Cached | RAM used for file cache |
SwapTotal | Total swap space |
SwapFree | Unused swap |
Dirty | Memory waiting to be written to disk |
HugePages_Total | Huge pages configured |
MemAvailable is the important one for "how much memory is free" — it accounts for reclaimable cache. MemFree alone is misleading because Linux aggressively uses free RAM for caching.
Kernel version and boot parameters
cat /proc/versionLinux version 6.1.0-18-amd64 (debian-kernel@lists.debian.org) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT_DYNAMIC Debian 6.1.76-1 (2024-02-01)
Boot parameters passed to the kernel:
cat /proc/cmdlineBOOT_IMAGE=/boot/vmlinuz-6.1.0-18-amd64 root=UUID=abc123 ro quiet splash
Uptime
cat /proc/uptime86423.45 337821.23
First number is seconds since boot. Second is cumulative idle time across all CPUs. To make it readable:
uptimeLoaded filesystems
cat /proc/filesystemsShows all filesystem types the kernel currently supports — both built-in and loaded via modules.
Per-process information
Every running process has a directory in /proc named by its PID. We touched on this in the process management post — here is more detail.
ls /proc/1/Key files:
| File | Contents |
|---|---|
cmdline | Full command line, null-byte separated |
status | Human-readable process status |
stat | Machine-readable process stats (used by ps, top) |
maps | Memory mappings |
smaps | Detailed memory map with sizes |
fd/ | Symlinks to all open file descriptors |
fdinfo/ | File descriptor positions and flags |
net/ | Network state from this process's namespace |
environ | Environment variables (null-byte separated) |
cgroup | cgroup membership |
limits | Resource limits |
io | I/O statistics |
Reading a process's command line cleanly:
tr '\0' ' ' < /proc/1/cmdline
echoOpen files for a process:
ls -la /proc/1234/fd/Each entry is a symlink to the actual file. File descriptor 0 is stdin, 1 is stdout, 2 is stderr.
Memory usage breakdown:
cat /proc/1234/smaps | grep -E "^(Size|Rss|Pss):" | awk '{sum[$1]+=$2} END {for (k in sum) print k, sum[k], "kB"}'/proc/net
Network state from the kernel's perspective:
cat /proc/net/dev # interface statistics
cat /proc/net/tcp # TCP connections (hex format)
cat /proc/net/tcp6 # IPv6 TCP connections
cat /proc/net/udp # UDP sockets
cat /proc/net/route # routing table (hex)
cat /proc/net/arp # ARP table
cat /proc/net/if_inet6 # IPv6 addresses/proc/net/tcp is raw but contains everything ss and netstat read. The local and remote addresses are in little-endian hex:
# Decode a hex address like 0F02000A:0050
printf "%d.%d.%d.%d\n" 0x0A 0x00 0x02 0x0F # IP
printf "%d\n" 0x0050 # port 80/proc/sys
/proc/sys is where runtime kernel parameters live. Reading a file shows the current value. Writing to it changes the behaviour of the running kernel immediately.
cat /proc/sys/kernel/hostname
cat /proc/sys/vm/swappiness
cat /proc/sys/net/ipv4/ip_forwardChange IP forwarding (required for routing/NAT):
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forwardChange swappiness (how aggressively the kernel swaps):
echo 10 | sudo tee /proc/sys/vm/swappinessThese changes are immediate but not persistent. To make them permanent, use sysctl — covered in the next post.
/proc/interrupts
Shows hardware interrupt counts per CPU:
cat /proc/interruptsUseful for diagnosing interrupt affinity issues on multi-core systems, or seeing which devices are generating excessive interrupts.
/proc/iomem and /proc/ioports
Physical memory and I/O port ranges claimed by hardware:
cat /proc/iomem
cat /proc/ioportsUseful for low-level hardware debugging.
/proc/buddyinfo and /proc/slabinfo
Kernel memory allocator state:
cat /proc/buddyinfo # buddy allocator free pages by order
cat /proc/slabinfo # slab allocator cache statisticsslabinfo shows the kernel's internal object caches — dentries (directory entries), inodes, socket buffers, and more. Memory fragmentation and slab pressure show up here before they show up in application behaviour.
/proc is the kernel talking directly to you. Everything the kernel knows about the system is exposed here as readable files. Tools like ps, top, ss, netstat, and free are just convenient wrappers around what you can read directly from /proc yourself.
Next up: the /sys filesystem — hardware topology, driver bindings, and udev rules.