Linux Directory Structure (Filesystem Hierarchy Standard - FHS)¶
Every Linux system follows a standardized directory structure called the Filesystem Hierarchy Standard (FHS). Understanding this structure is essential for Linux administration, DevOps, Cloud Engineering, and troubleshooting production systems.
Learning Path¶
Course Progress
What You'll Learn¶
After completing this lesson, you'll be able to:
- Understand the Linux Filesystem Hierarchy Standard (FHS)
- Navigate important Linux directories
- Know where Linux stores configuration files
- Understand where applications, logs, and user data reside
- Learn directory best practices for production environments
Prerequisites¶
Before starting this lesson, complete:
- Introduction to Linux
- Linux History and Open Source
- Linux Fundamentals — Distributions and Architecture
- Linux Kernel Explained
- Linux Desktop vs Server Editions
- Linux Installation
- Linux Boot Process
- First Login and Terminal
Why Learn the Linux Directory Structure?¶
Unlike Windows, Linux does not organize files using drive letters like:
Instead, everything starts from a single root directory (/).
Understanding where Linux stores system files, logs, user data, and applications is one of the most important skills for every Linux administrator.
Whether you're:
- Troubleshooting a server
- Deploying applications
- Managing Kubernetes
- Configuring Docker
- Working in the cloud
you'll constantly navigate the Linux filesystem.
What is FHS?¶
FHS stands for Filesystem Hierarchy Standard.
It defines where files and directories should be stored in Linux.
Because of FHS:
- Ubuntu
- Debian
- Rocky Linux
- RHEL
- Fedora
all organize their files similarly.
This consistency makes Linux administration easier across different distributions.
Linux Filesystem Overview¶
/
(Root Directory)
├── bin
├── boot
├── dev
├── etc
├── home
├── lib
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin
├── srv
├── sys
├── tmp
├── usr
└── var
Everything begins at the Root Directory (/).
Root Directory (/)¶
The root directory is the top-most directory in Linux.
It contains every file and directory on the system.
Do not confuse:
with
They are different.
/bin¶
Contains essential user commands.
Examples:
These commands are available even during system recovery.
/boot¶
Contains files required during the boot process.
Examples:
- Linux Kernel
- GRUB configuration
- Initramfs
Example:
/dev¶
Contains device files.
Everything in Linux is treated as a file—including hardware devices.
Examples:
/etc¶
One of the most important directories.
Contains system configuration files.
Examples:
As a Linux administrator, you'll spend a lot of time inside /etc.
/home¶
Contains home directories for normal users.
Example:
Each user stores:
- Documents
- Downloads
- Scripts
- Projects
- Personal configuration files
/lib¶
Contains essential shared libraries required by system programs.
Similar to DLL files in Windows.
/media¶
Used for automatically mounted removable devices.
Examples:
- USB Drives
- DVDs
- External Hard Disks
/mnt¶
Temporary mount point.
Administrators commonly mount:
- NFS
- SMB
- Temporary disks
Example:
/opt¶
Contains optional third-party software.
Examples:
/proc¶
A virtual filesystem.
It doesn't store actual files.
Instead, it provides runtime information about:
- Processes
- Memory
- CPU
- Kernel
Example:
View memory:
/root¶
Home directory of the root user.
Example:
Normal users should never store files here.
/run¶
Stores temporary runtime information.
Examples:
- Process IDs
- Runtime sockets
- Lock files
Contents are recreated every boot.
/sbin¶
Contains essential system administration commands.
Examples:
These commands are primarily intended for system administrators.
/srv¶
Stores data served by system services.
Examples:
- Web Content
- FTP Files
- Application Data
Not all distributions use this directory extensively.
/sys¶
Virtual filesystem providing information about hardware and kernel devices.
Example:
/tmp¶
Temporary files.
Applications use this directory for temporary storage.
Files may be deleted automatically after reboot.
Example:
/usr¶
Contains user applications and libraries.
Subdirectories include:
Most installed software resides under /usr.
/var¶
Stores variable data.
Examples:
- Logs
- Databases
- Cache
- Web Content
Examples:
Important Directories for DevOps Engineers¶
| Directory | Why It Matters |
|---|---|
| /etc | Configuration |
| /var/log | Logs |
| /home | User Files |
| /opt | Third-party Software |
| /usr | Applications |
| /tmp | Temporary Files |
| /proc | System Information |
Visual Directory Hierarchy¶
/
├── bin → Essential Commands
├── boot → Boot Files
├── dev → Devices
├── etc → Configuration
├── home → User Data
├── lib → Libraries
├── media → Removable Media
├── mnt → Temporary Mounts
├── opt → Optional Software
├── proc → Process Information
├── root → Root User Home
├── run → Runtime Data
├── sbin → System Commands
├── srv → Service Data
├── sys → Kernel Information
├── tmp → Temporary Files
├── usr → User Programs
└── var → Logs & Variable Data
Hands-on Lab¶
Explore your Linux filesystem.
List root directories:
Display current directory:
Navigate to configuration files:
View logs:
Display CPU information:
Display memory information:
Return to home:
Production Perspective¶
Understanding the Linux directory structure is critical when troubleshooting production systems.
Examples:
| Task | Directory |
|---|---|
| Check SSH configuration | /etc/ssh |
| Investigate system logs | /var/log |
| Verify installed applications | /usr/bin |
| Inspect mounted filesystems | /etc/fstab |
| Analyze hardware | /proc and /sys |
| Review application data | /var/lib |
When responding to incidents, knowing where to look can significantly reduce troubleshooting time.
Best Practices¶
- Never modify system files without understanding their purpose.
- Store personal files in your home directory.
- Keep application configuration under
/etc. - Regularly monitor
/var/logfor system events. - Avoid storing important data in
/tmp.
Common Mistakes¶
❌ Confusing / with /root.
✅ / is the root of the filesystem, while /root is the home directory of the root user.
❌ Storing application data in system directories.
✅ Store application data in appropriate locations such as /var or user directories.
❌ Deleting files from /etc without backups.
✅ Always back up configuration files before making changes.
Interview Questions¶
Beginner¶
- What is the root directory in Linux?
- What does FHS stand for?
- Which directory stores configuration files?
- Which directory contains user home directories?
- Where are Linux logs stored?
Intermediate¶
- Explain the purpose of
/proc. - What is the difference between
/mediaand/mnt? - Why does Linux use a single directory hierarchy?
Architect Level¶
- How does understanding FHS help in production troubleshooting?
- Why is maintaining a standard filesystem hierarchy important across Linux distributions?
- Which directories would you inspect during a production incident involving a web server?
Summary¶
In this lesson, you learned:
- What the Filesystem Hierarchy Standard (FHS) is
- The purpose of each major Linux directory
- Where Linux stores configuration files, logs, applications, and user data
- How the Linux filesystem supports administration and troubleshooting
Understanding the Linux directory structure is a foundational skill that you'll use throughout your Linux, Cloud, DevOps, and Platform Engineering journey.
Key Takeaways¶
- Linux uses a single hierarchical filesystem rooted at
/. - Configuration files are stored in
/etc. - User files are stored in
/home. - Logs are stored in
/var/log. - Runtime system information is available through
/procand/sys. - Mastering FHS makes system administration and troubleshooting much easier.
What's Next?¶
Getting Help in Linux (man, info, --help)
In the next lesson, you'll learn how to:
- Use the
mancommand - Navigate manual pages
- Use the
infosystem - Understand
--helpoutput - Find command documentation efficiently
- Become a self-sufficient Linux learner