Frequently Asked Question

What is /proc and why don't the files have a size?

/proc is a virtual filesystem generated by the kernel, none of its files live on disk, and ls -l shows them as zero bytes because the kernel doesn't know how big the content will be until you ask. When you read /proc/cpuinfo, the kernel synthesises the text on the spot from its current view of the CPU. When you read /proc/meminfo, you get a fresh snapshot of memory statistics. When you read /proc/123/cmdline, you get the command line of process 123 as it stood the instant you read.

Each running process has its own subdirectory at /proc/<PID>/: cmdline is its arguments, status and stat are scheduler and memory statistics, maps is its address-space layout, fd/ is one symlink per open file descriptor. Tools like ps, top, htop, and lsof are largely formatted views over /proc. A few writable files under /proc/sys/ let root change kernel tunables on the fly, for example /proc/sys/net/ipv4/ip_forward enables IP forwarding.

Video

Further reading and video