Device Files, /proc & /sys

Devices, /proc and /sys

One of Linux's defining ideas is "everything is a file" - and hardware and kernel internals are no exception. Instead of needing a special API to ask the kernel "how much memory is free?", you just read a file. This means the ordinary tools you already know (cat, grep, redirection) work on system information too.

Analogy: /proc and /sys are like a car's dashboard. The engine isn't inside the dashboard - but the dashboard gives you a live, always-current window into what the engine is doing right now. Read /proc/meminfo and you get this instant's memory numbers, not a cached snapshot from boot.

Hardware discovery commands - these ask the kernel to summarize what it has found, rather than making you read /proc//sys by hand:

CommandShows
lspciPCI devices (GPU, NIC)
lsusbUSB devices
lsblkBlock devices (disks/partitions)
lscpuCPU architecture
dmidecodeFirmware/DMI hardware info
dmesgKernel ring buffer (boot & hardware messages)
$ lscpu | grep '^CPU(s):'
CPU(s):                  4

That one line answers "how many logical CPUs does this machine have?" - useful context later when you're reading load averages or deciding how many parallel jobs to run.

Try cat /proc/cpuinfo, lsblk, and dmesg | tail in the terminal below - notice that cating /proc/cpuinfo works exactly like reading a normal text file, even though there's no such file on any physical disk.