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 varThe 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.
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.
Where would you expect the system's configuration files?
A program's log file keeps growing every day. Which branch is it most likely under?
What is /root?
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/usrwith user files.
