The Linux Filesystem: Where Everything Lives
Learn the unified Linux directory tree — /home, /etc, /var, /dev, /proc and more — and understand why everything in Linux is a file.
One of the first things that confuses Windows users switching to Linux is the directory structure. There's no C:\, no drive letters — just a single tree starting from /. Once you understand this tree, navigating Linux becomes intuitive.
Everything Is One Tree
In Linux, everything starts from a single root directory: / (called "root" or "slash"). Every file, every device, every process — all live somewhere under this one tree.
Windows uses separate trees per drive (C:\, D:\). Linux has one unified tree. USB drives, network shares, even virtual system info — everything is mounted somewhere under /.
Essential Directories
The Linux Directory Tree
| Directory | Purpose | Examples |
|---|---|---|
/ | Root — top of everything | Starting point |
/home | User home directories | /home/sagar, /home/john |
/root | Root user's home | Only accessible by root |
/etc | System configuration files | /etc/passwd, /etc/nginx/ |
/bin | Essential user binaries | ls, cp, cat, grep |
/sbin | System admin binaries | fdisk, iptables, reboot |
/usr | User programs and data | /usr/bin, /usr/lib |
/var | Variable data (changes often) | Logs, databases, cache |
/tmp | Temporary files (cleared on reboot) | Scratch space |
/dev | Device files | /dev/sda, /dev/null |
/proc | Process info (virtual) | /proc/cpuinfo, /proc/meminfo |
/sys | System/kernel info (virtual) | Hardware info |
/boot | Boot loader files | Kernel, GRUB |
/lib | Shared libraries | Like DLLs in Windows |
/opt | Optional/third-party software | Custom installs |
/media | Removable media mount points | USB drives, CDs |
/mnt | Temporary mount points | Manually mounted FSes |
/home — Your Personal Space
Each user gets a personal directory under /home. This is where your documents, config files, projects, and settings live. The shortcut ~ (tilde) always points to your own home directory, regardless of who you are or where you are in the filesystem.
Hidden files (dotfiles) start with a . and store per-user settings for programs like bash, git, vim, etc.
/home/
├── sagar/ ← Your home directory (~)
│ ├── Documents/
│ ├── Downloads/
│ ├── Desktop/
│ ├── .bashrc ← Hidden config file (note the dot)
│ ├── .ssh/ ← SSH keys and config
│ └── Projects/
└── john/
├── Documents/
└── .../etc — Configuration Central
/etc (from "et cetera") holds system-wide configuration files — plain text files that control how services, users, networking, and the OS itself behave. You'll spend a lot of time here as a sysadmin.
/etc/
├── passwd ← User accounts (no passwords here!)
├── shadow ← Encrypted password hashes
├── group ← Group definitions
├── hostname ← System hostname
├── hosts ← Local DNS: IP → hostname mappings
├── fstab ← Filesystem mount table (what mounts at boot)
├── ssh/
│ └── sshd_config ← SSH server configuration
├── nginx/
│ └── nginx.conf ← Web server configuration
└── apt/
└── sources.list ← Package repository URLs/var — Variable Data
/var holds data that changes constantly while the system runs — log files growing as events happen, mail queues building up, database files being written to. If you're debugging a system problem, /var/log/ is where you look first.
/var/
├── log/ ← System logs (VERY important for debugging)
│ ├── syslog ← General system messages
│ ├── auth.log ← Login attempts, sudo usage
│ └── nginx/ ← Web server access/error logs
├── cache/ ← Application cache (safe to delete)
├── mail/ ← Email storage
└── tmp/ ← Temp files that survive reboots (unlike /tmp)/dev — Everything Is a File
One of Linux's foundational principles: everything is a file — even hardware devices.
Your hard disk is a file. Your terminal is a file. There's even a file that discards everything written to it (/dev/null — the "black hole" of Linux) and one that generates infinite zeros (/dev/zero).
Common Device Files
| File | What It Is |
|---|---|
/dev/sda | First SATA/SCSI hard disk |
/dev/sda1 | First partition on first disk |
/dev/nvme0n1 | First NVMe SSD |
/dev/null | Black hole — discards everything written to it |
/dev/zero | Infinite source of zero bytes |
/dev/random | Random number generator |
/dev/tty | Current terminal |
# Send output to the void (discard it)
some-noisy-command > /dev/null
# Discard both stdout and stderr
some-command > /dev/null 2>&1
# Generate 32 random bytes and base64-encode them (for secrets)
head -c 32 /dev/random | base64/proc — Processes as Files
/proc is a virtual filesystem — there are no real files on disk. The kernel generates its contents on the fly when you read from it. It's a window into the live state of the running system.
cat /proc/cpuinfo # CPU model, cores, flags
cat /proc/meminfo # RAM usage breakdown
cat /proc/version # Kernel version string
cat /proc/uptime # Seconds since boot (two numbers)
ls /proc/1/ # All info about PID 1 (systemd/init)
cat /proc/1/cmdline # The command that started PID 1Absolute vs Relative Paths
Path Types and Special Symbols
| Type | Starts With | Example | Description |
|---|---|---|---|
| Absolute | / | /home/sagar/notes.txt | Full path from root — works from anywhere |
| Relative | anything else | Documents/notes.txt | Relative to where you currently are |
| Symbol | Meaning | Example |
|---|---|---|
/ | Root directory | cd / |
~ | Your home directory | cd ~ = cd /home/sagar |
. | Current directory | ./script.sh |
.. | Parent directory (one level up) | cd .. |
- | Previous directory | cd - (toggle) |
# Absolute path — works from anywhere
ls /var/log/nginx
# Relative path — depends on where you are
ls log/nginx # Only works if you're already in /var
# Special symbol shortcuts
cd ~ # Go home
cd .. # Go up one level
cd ../.. # Go up two levels
cd - # Go back to previous directoryYou're debugging why a web server is failing. Which directory do you check first?
What does the `~` symbol represent in a Linux path?
Explore the filesystem:
- Run
ls /— list all the top-level directories and identify 3 that you now recognize - Run
ls /etc | head -20— what kind of files do you see? - Run
cat /proc/cpuinfo | grep "model name"— what CPU does your machine have? - Try sending output to the black hole:
echo "gone forever" > /dev/null— what happens?