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.
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
- 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). - 02
/homecontains one subdirectory per regular user (/home/amit) — this is where your own files, downloads, and personal config live, directly analogous toC:\Users\<you>on Windows. - 03
/etcholds 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,/etcis usually where you go looking. - 04
/varholds 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. - 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. - 06
/tmpis for temporary files that may be wiped on every reboot — never store anything here you actually need to keep./rootis the home directory specifically for therootsuperuser (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/login 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
One tree, rooted at / — no separate drive letters, no matter how many physical disks are involved.
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/logExplain it without notes
Why doesn't Linux have drive letters like C:\ and D:\, and what happens to a second physical disk instead?
You're debugging a misconfigured service on a Linux server. Which top-level directory do you check FIRST, and why?
Practice
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.
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
dformount(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 /.