EMZETT.
Login

/proc, /sys and tmpfs: File systems without a disk

In short: Linux presents information about processes, hardware and the kernel as files that are not on the disk at all but are generated by the kernel.

In more detail: The principle “everything is a file” goes far on Linux: even system state can be read and changed with ordinary commands such as cat and echo. These pseudo file systems take up no disk space; their contents are created in memory on access.

In Depth

/proc: processes and kernel state

For every running process there is a folder /proc/<PID>/ with the command line (cmdline), environment variables (environ), open files (fd/), memory mapping (maps) and status (status). General information: /proc/cpuinfo, /proc/meminfo, /proc/uptime, /proc/loadavg. Programs such as ps, top and free just read here. Under /proc/sys/ kernel parameters can be changed live, for example echo 1 > /proc/sys/net/ipv4/ip_forward. sysctl is the more convenient interface for that.

/sys: devices and drivers

/sys shows the kernel’s device structure (sysfs): network cards under /sys/class/net/, disks under /sys/block/, battery state under /sys/class/power_supply/. Some files are writable, such as the display brightness (/sys/class/backlight/.../brightness) or the CPU power-saving mode.

tmpfs: file system in memory

tmpfs stores files in RAM (partly in swap if needed). It is very fast and empty after a reboot. Typical: /run, /dev/shm, often /tmp. Create your own:

sudo mount -t tmpfs -o size=512m tmpfs /mnt/ramdisk

Memory is only used when files are written. Good for temporary data, fast builds or secrets that should never reach the disk.

Others and notes

devtmpfs (/dev) contains device files, cgroup2 the resource groups, debugfs, securityfs and tracefs developer interfaces. Changes in /proc and /sys apply only until reboot; make them permanent through sysctl.d, udev rules or services. Caution: wrong values can make the system unstable.

See also: File system hierarchy, Processes and signals, The Linux kernel, fstab and mount