Command Palette

Search for a command to run...

Hectal
PHASE 0Beginner ~14 min· topic 3 of 4

Topic 0.3

The Linux Filesystem Hierarchy

In one line

Every file on a Linux system lives under ONE single tree rooted at / — no separate drive letters like C:\ — and a handful of top-level directories have very specific, consistent meanings across every distro.

0/4 · 0%

Think of it like this

A well-organized office building versus a pile of loose folders on separate desks. Windows' C:\, D:\ model is like several separate buildings; Linux's single tree rooted at / is one building where every floor (directory) has a clearly defined PURPOSE, and everything — including other physical disks — gets mounted into that same tree somewhere.

Key ideas

  1. 01

    / (root) is the top of the entire filesystem — everything else is a subdirectory of it, including things that might physically be on a completely different disk (an external drive, a mounted network share) once it's been MOUNTED into the tree (Phase 7 covers mounting).

  2. 02

    /home contains one subdirectory per regular user (/home/amit) — this is where your own files, downloads, and personal config live, directly analogous to C:\Users\<you> on Windows.

  3. 03

    /etc holds SYSTEM-WIDE CONFIGURATION files — nearly every service and tool on a Linux machine keeps its config here as plain text files (e.g. /etc/nginx/nginx.conf, /etc/ssh/sshd_config). When something's 'set up wrong' on a Linux server, /etc is usually where you go looking.

  4. 04

    /var holds data that VARIES / changes while the system runs — most importantly /var/log (system and application logs, Phase 7) and often a web server's served files or a database's data directory.

  5. 05

    /usr (historically 'Unix System Resources', not 'user') holds the bulk of installed software and its files — most commands you run (/usr/bin/python3, /usr/bin/node) actually live here, not in some special 'Programs' folder.

  6. 06

    /tmp is for temporary files that may be wiped on every reboot — never store anything here you actually need to keep. /root is the home directory specifically for the root superuser (Phase 1 covers users/permissions), separate from regular users' homes under /home.

In your stack

  • →

    Your Spring Boot app's application.properties-driven logging often ends up under /var/log in a real deployment, and a systemd-managed JVM service's unit file (Phase 3) typically lives under /etc/systemd/system/ — both are direct, practical uses of this exact hierarchy.

Code & diagrams

FilesystemTreediagram

One tree, rooted at / — no separate drive letters, no matter how many physical disks are involved.

Rendering diagram…
explore-hierarchy.shmarkdown

A guided tour — run each one and actually look at what comes back.

# See the top-level structure of the entire filesystem
ls -l /

# Your own home directory
echo $HOME
ls -la ~

# System-wide configuration — just look, don't edit yet
ls /etc | head -20

# Where most installed commands actually live
which python3
which node
ls /usr/bin | wc -l

# Logs live here
ls /var/log

Explain it without notes

01

Why doesn't Linux have drive letters like C:\ and D:\, and what happens to a second physical disk instead?

02

You're debugging a misconfigured service on a Linux server. Which top-level directory do you check FIRST, and why?

Practice

01

Run ls -l / on any Linux system and try to guess the purpose of every top-level directory BEFORE looking anything up, then check yourself against this topic's bullets.

02

Find where a command-line tool you use often (git, python3, node) physically lives using which <command>, then confirm it's really there with ls -l on that exact path.

Trade-offs

  • ↔

    The single-tree model is more consistent and scriptable than drive letters (a script never needs to guess which letter a drive got assigned), but it does mean 'which physical disk is this file actually on' isn't obvious from the path alone — you need df or mount (Phase 7) to find that out.

Done when you can

  • I can name at least five top-level directories and what each is conventionally for.

  • I know /etc is where system-wide configuration lives and /var/log is where logs live.

  • I understand there are no drive letters — everything is one tree rooted at /.