Contents

Infrastructure & Operations › Linux & Servers

Linux Directory Structure

What /etc, /var, /usr, /home and /tmp are for.

Also known as: filesystem hierarchy, FHS, Linux file hierarchy

Linux has one directory tree starting at / (root), with no drive letters. Extra disks are attached somewhere in that tree. Distributions follow a common layout, so you can predict where things live.

PathWhat it is for
/homeUsers’ personal files (/home/alice). ~ is shorthand for your home.
/etcSystem-wide configuration files, mostly plain text
/varData that changes while the system runs: logs (/var/log), caches, mail queues, often databases
/usrInstalled programs and libraries (/usr/bin, /usr/lib)
/bin, /sbinEssential commands. On many modern distributions these point into /usr.
/tmpTemporary files, usually cleared on reboot
/optOptional, self-contained third-party software
/devDevice files such as disks
/proc, /sysVirtual files showing live information about the kernel and processes
/rootThe home directory of the root user

Where you’ll actually go

  • Config for a service: look in /etc (for example /etc/nginx/).
  • Why did it crash: look in /var/log. See system logs.
  • Your own app deployed by hand: commonly /opt or /srv, but this is a team convention.

Things to remember

  • Paths starting with / are absolute; anything else is relative to the current directory.
  • Don’t store important data in /tmp.
  • Running out of space in /var is a frequent cause of outages, because logs and databases live there. See disk space.
  • Some details vary between distributions, so confirm on the machine in front of you with ls /.