Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Navigation Basics  ›  Capstone Project

The Directory Hierarchy — One Tree from /

Directory Hierarchy Overview 15 minLinux has one directory tree rooted at /, with conventional branches such as /etc for configuration, /var for changing data, /usr for programs and /home for users.

The Directory Hierarchy — One Tree from /

On Windows you might think in drive letters: C:, D:. Linux has no drive letters. Every file on every disk hangs off a single tree that starts at /, called the root. Once you know what the main branches are for, you can guess where almost anything lives without searching.

The rule

One tree, one root: every path starts at /.

The top-level directories follow a shared convention, so they look much the same on most Linux systems:

Directory What lives there
/home one folder per user: /home/asha
/root the home folder of the root (administrator) user
/etc system-wide configuration files, mostly plain text
/var data that changes as the system runs: logs in /var/log, caches, mail queues
/usr installed programs and their files: /usr/bin, /usr/lib, /usr/share
/bin, /sbin essential commands; on most modern systems these just point into /usr
/tmp temporary files, often cleared at reboot
/opt optional, self-contained software packages
/boot the kernel and the files needed to start the system
/dev devices shown as files, such as disks (/dev/sda)
/proc a live view of running processes and kernel information, generated in memory
/mnt, /media places where extra disks and USB drives are attached

A second disk doesn't get a new letter. It is mounted onto a directory, such as /mnt/backup, and from then on its files look like any other part of the tree.

$ ls /
bin  boot  dev  etc  home  lib  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

The shortcut

To locate something, ask what kind of thing it is, not what it's called. Settings go in /etc. Things that grow and change go in /var. Programs go in /usr. People's own files go in /home. Throwaway files go in /tmp.

Where would Asha look?Step 1 of 5
  1. Her own harvest spreadsheet

    It belongs to a person, so it's in /home/asha/garden/harvest.csv.

Two look-alikes catch people out. /root is the administrator's home folder, while / is the root of the whole tree. Despite its name, /usr holds programs and libraries that everyone shares, not personal files. Your own files go in /home.

Drills

Answer fast — trust the rule.

quick drill

Where would you expect the system's configuration files?

quick drill

A program's log file keeps growing every day. Which branch is it most likely under?

quick drill

What is /root?

quick drill

Asha plugs in a USB drive. How does Linux usually make its files available?

Remember

  • One tree, one root: every path starts at /, and extra disks are mounted into that tree.
  • Ask what kind of thing it is: settings in /etc, changing data in /var, programs in /usr, people's files in /home, throwaway files in /tmp.
  • Don't mix up / with /root, or /usr with user files.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainWhere does it live?

A new team member asks where to find a web server's configuration, its error logs, the program itself and their own files. Explain where each lives in the Linux tree and the rule of thumb that lets you guess.