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.
/dev- device files.sda/nvme0n1(disks),tty(terminals),null,zero,random. These aren't "files about" devices - reading or writing them talks directly to the hardware. Managed dynamically by udev, a background service that creates and removes these entries as devices are plugged in and unplugged./proc- a virtual filesystem: it looks like ordinary files and directories, but nothing here actually exists on disk. The kernel generates its contents on the fly, live, the instant you read them./proc/cpuinfo,/proc/meminfo, and a numbered directory per running process (/proc/<pid>/) all work this way./sys- sysfs: a more structured, more recent virtual filesystem exposing devices, drivers, and kernel tunables in an organized tree (versus/proc's older, looser layout).
Analogy:/procand/sysare 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/meminfoand 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:
| Command | Shows |
|---|---|
lspci | PCI devices (GPU, NIC) |
lsusb | USB devices |
lsblk | Block devices (disks/partitions) |
lscpu | CPU architecture |
dmidecode | Firmware/DMI hardware info |
dmesg | Kernel 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.