Skip to content

Phase 3 · Free

3.2 The Filesystem Tree

Windows has C:, D:, and so on. Linux has one tree that starts at /, the root, and everything hangs off it: your files, the settings, the programs, even other disks. Once you know what the main folders are for, you can find anything on any Linux machine.

Phase 3. Lesson 2 of 7. About 20 minutes.

Plain entry

Windows has C:, D:, and so on. Linux has one tree that starts at /, the root, and everything hangs off it: your files, the settings, the programs, even other disks. Once you know what the main folders are for, you can find anything on any Linux machine.

Terms

  • Root directory (/): the top of the tree. Not the same as the root userThe administrator account on Linux and other Unix-like systems, with user ID 0 and unrestricted access to every file, process, and setting. Read more →.
  • Path: directions to a file. Absolute paths start with / (/etc/hostname). Relative paths start from where you are (notes/todo.md).
  • ~: your home directory. . is here. .. is one level up.
  • Mount: attaching a disk or partitionA defined section of a physical disk that the operating system treats as a separate unit, each usually holding its own filesystem. Read more → to a folder in the tree.
  • FHSFilesystem Hierarchy Standard: the standard that defines what goes where in a Linux directory tree, such as /etc for configuration and /var for logs. Read more →: the Filesystem Hierarchy Standard that says what goes where.

Depth

FolderWhat lives thereYou will touch it when
/etcSystem configuration, plain textChanging any setting
/homeUsers’ personal foldersEvery day
/rootRoot user’s homeRarely
/varData that changes: logs, caches, databases, websitesReading logs in /var/log
/tmpTemporary files, cleared at bootScratch work
/usrInstalled programs and librariesRarely edit by hand
/bin, /sbinEssential commands (links into /usr on Ubuntu)Never edit
/bootKernelThe core of an operating system that runs with full hardware control and decides how every program gets CPU time, memory, and device access. Read more → and bootloaderThe small program the firmware starts first, whose only job is to find the operating system kernel, load it into memory, and hand over control. Read more →Phase 4
/devDevices as files (/dev/sda)Disks
/proc, /sysLive kernel info, not on diskPhase 2
/mnt, /mediaWhere extra disks get mountedUSB drives
ls /
cat /etc/hostname
ls /var/log | head

Expected output (first command):

bin   boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  snap  srv  sys  tmp  usr  var

Going further

ls -l /bin shows /bin -> usr/bin: on modern Ubuntu, /bin is a link (the “usr merge”). findmnt shows every mount in the tree, including the virtual ones.

Why it works this way

Linux puts things where they are by what kind of data they are, not by which program owns them. Settings go in /etc so you can back up one folder and keep every setting. Changing data goes in /var so it can live on a bigger disk. That is also how you troubleshoot: a broken setting means look in /etc, a full disk often means look in /var, and a missing command means look at your PATH and /usr/bin.

Self-check

  1. Where do you look for system settings? For logs?
  2. Is notes/todo.md absolute or relative?
  3. What does cd .. do?

Answers: (1) /etc; /var/log. (2) Relative. (3) Moves up one folder.

Sources