Begin Linux

The Linux filesystem: where things live and why

Once you know where configuration, data and logs live, most troubleshooting becomes a question of looking in the right directory.

The map

PathWhat lives thereTypical task
/etcSystem-wide configuration, plain textEdit a service's config, then restart it
/varVariable data: logs, mail spools, databases, web rootsCheck /var/log first when something fails
/homeUser home directoriesPer-user settings in dotfiles like ~/.bashrc
/usrInstalled software and libraries (read-mostly)Rarely edit by hand; use the package manager
/optThird-party software installed outside the package systemVendor agents, self-contained apps
/tmpTemporary files, often cleared at bootScratch space; never store anything you need
/proc, /sysVirtual views of the kernel and hardwarecat /proc/cpuinfo, /proc/meminfo
/devDevice files: disks, terminals, randomlsblk to see disks before touching /dev/sdX
/bootKernel and bootloaderKeep free space; old kernels pile up here

Three rules of thumb

Everything is a file

Devices, kernel settings and even running processes are exposed as files. cat /sys/class/net/eth0/operstate tells you whether a network interface is up; ls /proc/1234/fd shows what process 1234 has open. This is why text tools like grep and less are enough for a surprising amount of administration.

Exercise: find the configuration file for the SSH server, the log it writes to, and the directory where a web server would serve files from. Verify each one exists on your system.