What is /proc in Linux, and is it a real folder on disk?
/proc is a virtual file system created by the kernel in memory. Its files show live information about running processes and the system, such as /proc/cpuinfo and /proc/PID/status. Nothing in it is stored on disk.
Explain it simply
/proc is like the dashboard of a car. The dashboard is not an engine part you can take out; it simply displays what the engine is doing right now. The kernel generates the files in /proc when you read them.
Each running process gets a folder named by its PID, for example /proc/1234/, with files such as cmdline (how it was started), status (memory and state) and fd/ (its open files). System-wide files include /proc/cpuinfo, /proc/meminfo and /proc/uptime.
Tools like ps, top and free mostly just read these files and format them nicely. File sizes show as 0 because there is no stored content.
Example
cat /proc/uptime
# 35120.45 270000.12 (seconds since boot, idle seconds)
head -2 /proc/meminfo
# MemTotal: 8023456 kB
# MemFree: 1203344 kB
cat /proc/$$/cmdline # the current shell's own commandWhat to say in the interview
"/proc is a virtual file system exposed by the kernel. It has no disk storage; reading a file asks the kernel for live data. Each process has a /proc/PID folder, and tools like ps, top and free read from here."
Common mistakes
- Trying to edit or free space in /proc; it takes no disk space.