Filesystem Fundamentals · #6 of 19
The Filesystem Hierarchy
Everything is a File
The Root of Everything
Unlike Windows (C:, D:, E:), Linux has a single root directory: /
Everything — files, directories, devices, processes — lives under this one tree.
The Filesystem Hierarchy Standard (FHS)
/ # Root — the top of the tree
├── bin/ # Essential binaries (ls, cp, cat)
├── boot/ # Bootloader and kernel
├── dev/ # Device files (disks, terminals)
├── etc/ # Configuration files
├── home/ # User home directories
│ └── username/ # Your files live here
├── lib/ # Shared libraries
├── media/ # Mounted removable media (USB drives)
├── mnt/ # Temporary mount points
├── opt/ # Optional/third-party software
├── proc/ # Virtual filesystem (process info)
├── root/ # Root user's home directory
├── run/ # Runtime data (PIDs, sockets)
├── sbin/ # System binaries (admin commands)
├── srv/ # Service data (web server files)
├── sys/ # Virtual filesystem (hardware info)
├── tmp/ # Temporary files (cleared on reboot)
├── usr/ # User programs and data
│ ├── bin/ # User binaries
│ ├── lib/ # User libraries
│ └── share/ # Shared data (docs, icons)
└── var/ # Variable data (logs, databases)
└── log/ # System logs
Key Directories Explained
/home — Your Home
Your personal space. Configuration, documents, downloads all go here.
/home/alice— Alice’s home~is shorthand for your home directory
/etc — Configuration
System-wide settings. All plain text files.
/etc/passwd— User accounts/etc/hostname— Computer name/etc/apt/sources.list— Package repositories
/var — Variable Data
Data that changes during operation.
/var/log— System logs/var/www— Web server files/var/cache— Cached data
/dev — Devices
Hardware represented as files.
/dev/sda— First hard disk/dev/sda1— First partition/dev/null— Black hole/dev/zero— Infinite zeros/dev/random— Random data
/proc and /sys — Virtual Filesystems
Not real files! The kernel generates these on-the-fly.
cat /proc/cpuinfo # CPU information
cat /proc/meminfo # Memory information
cat /sys/class/power_supply/BAT0/capacity # Battery level
“Everything is a File”
This is Linux’s most powerful abstraction:
| Thing | File Path |
|---|---|
| Hard disk | /dev/sda |
| USB drive | /dev/sdb1 |
| Terminal | /dev/tty1 |
| Random numbers | /dev/random |
| Null (discard) | /dev/null |
| Process info | /proc/[pid]/ |
| CPU temp | /sys/class/thermal/ |
This means you can use the same tools (cat, echo, read) for everything!
Absolute vs Relative Paths
Absolute path: Starts from root (/)
cd /home/user/Documents
Relative path: Starts from current location
cd Documents # If you're in /home/user
cd ../Downloads # Go up one, then into Downloads
Special Directories
.— Current directory..— Parent directory~— Home directory-— Previous directory (for cd)
Navigating the Tree
# Where am I?
pwd
# What's here?
ls
# Go to root
cd /
# Explore!
ls /etc
ls /var/log
cat /etc/os-release
# Go home
cd ~
# or just
cd