What is the Linux Directory Structure?
In Linux, everything starts from / (called root). It's the top of the file system tree, and all other directories branch out from there. Unlike Windows with C:, D:, E: drives, Linux has one unified tree where everything - programs, files, even hardware - shows up as files or directories.
Think of it like: A real tree where / is the trunk and all directories are branches growing from it. No matter how many hard drives you have, they all fit into this one tree.
Windows vs Linux Approach
Windows
C:\Windows\System32
C:\Program Files\
D:\Games\
E:\Backup\
Multiple separate roots (C:, D:, E:)
Each drive has its own letter. Programs look in different places depending on the drive.
Linux
/usr/bin/
/home/john/
/var/log/
/mnt/backup/
One unified tree starting at /
Everything starts at root (/). All drives mount somewhere in this tree. Clean and consistent.
The Linux File System Tree
graph TD
Root["/"]
Root --> Bin["/bin"]
Root --> Home["/home"]
Root --> Etc["/etc"]
Root --> Var["/var"]
Root --> Usr["/usr"]
Root --> Tmp["/tmp"]
Root --> Opt["/opt"]
Root --> Dev["/dev"]
style Root fill:#fef3c7,stroke:#f59e0b,stroke-width:4px,font-size:18px
style Home fill:#dbeafe,stroke:#3b82f6,stroke-width:3px
style Etc fill:#fce7f3,stroke:#ec4899,stroke-width:3px
style Var fill:#dcfce7,stroke:#16a34a,stroke-width:3px
style Usr fill:#e0e7ff,stroke:#6366f1,stroke-width:3px
style Bin fill:#fef9c3,stroke:#eab308,stroke-width:3px
style Tmp fill:#fed7aa,stroke:#ea580c,stroke-width:3px
style Opt fill:#ddd6fe,stroke:#8b5cf6,stroke-width:3px
style Dev fill:#fecaca,stroke:#dc2626,stroke-width:3px
Everything branches from / (root). Each directory has a specific purpose in the system.
Important Directories You Need to Know
/
Root directory. The top of everything. All other directories live here.
cd / you go to the very top of the file system.
/home
User home directories. Each user gets their own folder here. Your personal files, documents, downloads - everything goes in your home directory.
/home/john/ where all his stuff lives. Like C:\Users\John in Windows.
/bin
Essential commands. Basic programs everyone needs like ls, cp, cat. These work even in emergency recovery mode.
ls, Linux runs /bin/ls to list files.
/etc
Configuration files. All system settings live here. Want to change how your network works or what programs start on boot? Look in /etc.
/etc/hosts maps website names to IP addresses. /etc/passwd has user account info.
/usr
User programs and data. Most of your installed software lives here. Think of it as "C:\Program Files" but organized better.
/usr/bin/ has programs like Firefox or vim. /usr/lib/ has shared libraries programs need.
/var
Variable data. Stuff that changes as the system runs - logs, caches, databases, mail queues. Things that grow over time.
/var/log/ has system logs. If something breaks, look here. /var/cache/ stores temporary cached data.
/tmp
Temporary files. Anything here can disappear on reboot. Programs use it for scratch space. Don't store important stuff here.
/tmp/, then saves the result elsewhere.
/opt
Optional software. Third-party applications that don't fit the standard Linux layout go here. Each app gets its own subdirectory.
/opt/google/chrome/ for Chrome browser. /opt/slack/ for Slack app.
/root
Root user's home. This is the admin (root user) home directory. Not to be confused with / (root directory). Regular users can't access this.
sudo su to become root, you land in /root/.
Less Common But Still Important
-
/dev: Device files. Your hard drives, USB sticks, even your terminal show up here as files.
/dev/sdais your first hard drive. - /proc: Virtual files showing system info. CPU details, memory usage, running processes - all readable as files here.
-
/mnt & /media: Mount points for external drives. When you plug in a USB drive, it shows up in
/media/. Admins mount drives manually in/mnt/. - /sys: Another virtual file system. Info about hardware and kernel modules. You rarely touch this directly.
- /boot: Files needed to start the system. Kernel and bootloader live here. Don't delete anything from here!
- /lib: Shared libraries that programs need to run. Like DLL files in Windows.
Common Tasks and Where to Look
graph LR
A[What are you doing?] --> B[Installing software?]
A --> C[Looking for logs?]
A --> D[Editing config?]
A --> E[Saving your files?]
B --> B1["/usr/bin/ for programs
/usr/lib/ for libraries"]
C --> C1["/var/log/ has all logs"]
D --> D1["/etc/ has config files"]
E --> E1["/home/username/ for your stuff"]
style A fill:#fef3c7,stroke:#f59e0b,stroke-width:2px
style B1 fill:#dbeafe,stroke:#3b82f6,stroke-width:2px
style C1 fill:#dcfce7,stroke:#16a34a,stroke-width:2px
style D1 fill:#fce7f3,stroke:#ec4899,stroke-width:2px
style E1 fill:#e0e7ff,stroke:#6366f1,stroke-width:2px
Quick Tips
Use ~ as a shortcut to your home
Instead of typing /home/john/Documents/, just type ~/Documents/. The ~ always points to your home directory.
Path separator is / not \
Linux uses forward slashes. /home/john/file.txt not \home\john\file.txt like Windows.
Case matters!
File.txt and file.txt are different files in Linux. Always watch your capitalization.
/root is not the same as /
/ is the root directory (top of the tree). /root is the administrator's home folder. Don't mix them up!