The Filesystem Hierarchy

Linux organises everything under a single root directory / following a standard layout.

Unlike Windows with its C: and D: drives, Linux has a single tree that starts at the root directory /. Every disk and device is attached somewhere inside this one tree.

Linux filesystem hierarchy tree/ (root)/bin/etc/home/var/usrprogramsconfig/home/alice/home/boblogs, data
Everything hangs off a single root directory.

Key directories

PathHolds
/bin, /usr/binPrograms and commands.
/etcSystem configuration files.
/homePersonal folders, one per user.
/varChanging data — logs, mail, caches.
/tmpTemporary files (cleared on reboot).
/rootThe home directory of the root user.

Example

Example · bash
# List the top level of the whole system
ls /
# bin  boot  dev  etc  home  lib  root  tmp  usr  var

# Configuration lives in /etc
ls /etc/ssh

# Logs live in /var/log
ls /var/log

When to use it

  • A package maintainer places the app binary in '/usr/bin' and configuration in '/etc/myapp/' following the Filesystem Hierarchy Standard so users know where to look.
  • A sysadmin checks '/var/log/auth.log' during a security incident because FHS guarantees authentication logs live under '/var/log'.
  • A developer mounts a Docker volume at '/var/lib/myapp/data' because the FHS specifies '/var/lib' for persistent application state.

More examples

Explore top-level FHS directories

Lists the top-level FHS directories that form a predictable map of every Linux filesystem.

Example · bash
ls /
# bin   boot  dev  etc  home  lib  media  mnt
# opt   proc  root run  srv   sys  tmp    usr  var

Locate config and logs by FHS

Demonstrates that FHS tells you exactly where to find configs (/etc), logs (/var/log), and temp files (/tmp).

Example · bash
# Configuration always lives in /etc
ls /etc/nginx/

# Variable data and logs always in /var
ls /var/log/

# Temporary files in /tmp (cleared on reboot)
ls /tmp/

Find binary locations by FHS

Shows how the FHS separates system binaries (/bin, /sbin) from locally installed software (/usr/local/bin).

Example · bash
# System-essential binaries
ls /bin/

# User-installed binaries
ls /usr/local/bin/

# Where is a specific binary?
which nginx
# /usr/sbin/nginx

Discussion

  • Be the first to comment on this lesson.