Linux Filesystem Hierarchy

Vishnu MohanVishnu Mohan
3 min read

Familiarising yourself with the Linux filesystem hierarchy is very useful, especially if you’re working in DevOps, system administration roles. It helps you:

  • Troubleshoot system issues

  • Understand logs and services

  • Write correct paths in scripts/configs

  • Debug package installations, system performance, etc.


Overview of Important Linux Directories

DirectoryPurposeTypical Use
/Root of the entire filesystemEverything starts here
/binEssential user binariesCommands like ls, cp, mv, etc.
/sbinSystem binariesCommands for system admin (e.g., reboot, ifconfig)
/etcConfiguration filesConfigs for system and apps (e.g., /etc/hosts, /etc/nginx/)
/devDevice filesRepresents hardware (e.g., /dev/sda, /dev/null)
/procKernel and process info (virtual)Runtime system info like /proc/cpuinfo
/sysSystem info (virtual)Exposes hardware/driver info from kernel
/lib, /lib64Essential shared librariesNeeded for binaries in /bin, /sbin
/usrUnix System Resources and dataNon-essential apps and libraries (/usr/bin, /usr/lib)
/varVariable dataLogs, mail, cache (/var/log, /var/cache)
/tmpTemporary filesDeleted at boot, used by apps
/homeUser home directoriese.g., /home/vishnu
/rootRoot user’s homeNot the same as /
/optOptional softwareThird-party apps
/bootBoot filesKernel, initramfs, GRUB
/media, /mntMounted filesystemsFor USB drives, external partitions

Simple short-forms to help retain:

  • /etc = “etcetera” → miscellaneous configs

  • /var = “variable” → data that changes often

  • /usr = “unix system resources” (historically, not just userland)

  • /dev = “devices”

  • /proc = “processes” (runtime virtual info)


What about /var and /lib? and /var/lib?

/var, /lib, and /var/lib are critical parts of the Linux filesystem, and it's very helpful to know how they relate and differ.

  1. /var

    • As the name suggest /var stores variable (changing) data or the things that grow or change during system operation

    • This is opposite of /usr, which is static and read-only post-install

  2. /lib

    • stores essential shared libraries needed by binaries in /bin and /sbin , you can think of it as a place to hold core system libraries.

    • Without /lib, the system can’t even boot properly

  3. /var/lib

    • While /lib stores shared libraries and system libraries, /var/lib stores stateful runtime data for system services and apps

    • This is where where services track what they're doing

    • eg: /var/lib/docker is where docker service stores all it’s runtime variable data like volume, images and even overlays.

It is useful to understand this diff especially for DevOps engineers while working with services like docker!!


While it is useful to familiarise with these commands, I do not think memorising them would stick with you as you often tend to forget things that you don’t use, so instead I recommend bookmarking this article for reference while actively poking around an actual systems, exploring these directories as you work on day to day tasks and this will help you stick with it in the long run as you are figuring out details about each directory as your requirements instead of directly asking chat-gpt to find it for you.


0
Subscribe to my newsletter

Read articles from Vishnu Mohan directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Vishnu Mohan
Vishnu Mohan

Software Engineer | Cloud Security