
Image retained from the original article.
Originally published 21 June 2023; rewritten and reviewed on 15 October 2026.
A service fails at 2 a.m., or a VPS starts throwing “No space left on device” errors, and the first challenge is deciding where to look. Linux’s directory layout stops feeling like trivia the moment you connect each path to three operational questions: where is the configuration, where does persistent data live, and which files are safe to rotate or lose on reboot?
Mapping Directories to Operational Roles
| Location | What to look for |
|---|---|
/etc |
Host and service configuration (Nginx, PHP, systemd overrides, SSH) |
/var/log |
File-based logs for web servers, mail, and cron |
/var/lib |
Persistent state maintained by databases, Docker, and package managers |
/home |
Ordinary users’ home directories and personal SSH keys |
/root |
The root user’s home directory, separate from / |
/tmp |
Temporary scratch space, often cleared on reboot or by age policy |
/run |
Runtime state such as PID files and sockets, recreated on boot |
/usr |
Installed binaries, libraries, and shared read-only resources |
/opt |
Third-party or vendor software installed outside standard packages |
/dev, /proc, /sys |
Virtual kernel and device interfaces, not real disk storage |
Modern distributions also flatten older conventions. On current Debian and Ubuntu systems, /bin, /sbin, and /lib are typically symlinks pointing into /usr/bin, /usr/sbin, and /usr/lib. You can verify this in seconds with ls -ld /bin /lib instead of assuming a textbook diagram matches your host.
Trace the Service Before Touching Anything
Never guess where an application keeps its files solely from the directory name. When troubleshooting an Nginx site, a MariaDB instance, or an ASP.NET Kestrel app running behind systemd, read the unit file and service config first:
systemctl status myapp.service
systemctl cat myapp.service
Look closely at WorkingDirectory, ExecStart, and any EnvironmentFile path. A custom web app might keep its binaries in /opt/myapp, its config in /etc/myapp/appsettings.Production.json, and its uploaded assets in /var/lib/myapp/uploads—or someone might have deployed everything straight into /var/www/.
Logs follow the same rule. While Nginx writes to /var/log/nginx/access.log and error.log, many modern daemons write exclusively to systemd-journald (journalctl -u myapp.service -n 100 --no-pager) rather than creating plain text files under /var/log.
Finding What Actually Filled the Disk
When / hits 100% capacity, guessing is dangerous. Deleting files under /var/lib/mysql or /var/lib/docker because /var looks huge is a fast way to corrupt a database or wipe container volumes. Start by measuring top-level usage and drilling down:
df -h
du -xh --max-depth=1 /var | sort -h
The -x flag keeps du from crossing into separate mounted filesystems, and -h makes the output readable. If df -h reports a full disk while du cannot account for the missing gigabytes, check for deleted files still held open by a running process—a classic issue after manually removing an active log file without reloading Nginx or PHP-FPM:
lsof +L1
Until that process is reloaded or restarted, the kernel keeps those unlinked blocks allocated on disk.
Inspect Before Modifying
Make pwd, ls -la, stat, and readlink -f part of your muscle memory before running any destructive command. Knowing whether a path is a real directory, a symlink, or a mount point prevents accidental deletions across boundaries. The goal is not to memorise every subdirectory on a fresh install, but to know where the system keeps its configuration, state, and evidence when something breaks.