Linux File System Hierarchy Explained Simple Guide

Related Courses

Next Batch : Invalid Date

Linux File System Hierarchy Explained - Understand Every Directory the Simple Way

Introduction: Why Linux File System Matters

In Linux, everything is organized in a structured and logical way. Unlike some operating systems where files are scattered across drives, Linux follows a single-root hierarchical file system. Every file, directory, device, and process is part of one unified tree.

Understanding this structure is essential for:

  • System administration

  • DevOps and cloud operations

  • Server management

  • Troubleshooting

  • Software development

  • Security and permissions

When you clearly understand where things live in Linux, managing the system becomes simple and predictable.

The Big Idea: Single Root Structure

Linux starts with a single top-level directory called:
/

This is known as the Root Directory. Everything in Linux grows from this root like branches of a tree.

There are no separate drives like C:, D:, or E:. Even external storage, USB drives, and network storage are mounted somewhere inside this tree.

Overview of Important Linux Directories

Let us explore the most important directories in Linux one by one.

/ - Root Directory (The Base of Everything)

The root directory is the top of the file system. Every other directory exists under it.

It contains essential system folders required for booting and operating the system.

You normally do not store personal files here.

/bin - Essential User Commands

The /bin directory contains basic commands required for system operation and user tasks.

Examples:

  • ls → list files

  • cp → copy files

  • mv → move files

  • rm → remove files

  • cat → view file content

  • pwd → show current directory

These commands are required even when the system is in minimal mode.

/sbin - System Administration Commands

This directory contains commands mainly used by system administrators.

Examples:

  • reboot

  • shutdown

  • fsck (file system check)

  • mount

  • iptables

These are essential for system control and maintenance.

/etc - Configuration Files

/etc contains configuration files for the entire system.

Examples:

  • Network configuration

  • User account settings

  • System startup configuration

  • Service configuration

Common files:

  • /etc/passwd → user information

  • /etc/shadow → encrypted passwords

  • /etc/hosts → hostname mapping

  • /etc/fstab → file system mount settings

This directory is critical for system behavior.

/home - User Personal Directories

Each user has a personal directory under /home.

Example:
/home/user1
/home/user2

This directory contains:

  • Personal files

  • Documents

  • Downloads

  • User configurations

  • Desktop data

Normal users mostly work inside /home.

/root - Root User Home Directory

This is the home directory for the root (administrator) user.

It is separate from /home for security and system control.

Only root user has full access here.

/usr - User Applications and Programs

/usr contains most installed applications and libraries.

Subdirectories:

  • /usr/bin → User programs

  • /usr/sbin → Admin programs

  • /usr/lib → Libraries

  • /usr/share → Shared files

Most software installed using package managers goes here.

/var - Variable Data (Frequently Changing)

This directory contains data that changes frequently.

Examples:

  • Log files → /var/log

  • Mail data → /var/mail

  • Cache → /var/cache

  • Spool → /var/spool

When debugging system issues, logs inside /var/log are very important.

/tmp - Temporary Files

Temporary files created by programs are stored here.

  • Files may be deleted automatically

  • Used by applications for temporary processing

  • Not meant for permanent storage

/dev - Device Files

In Linux, hardware devices are represented as files.

Examples:

  • /dev/sda → Hard disk

  • /dev/tty → Terminal

  • /dev/null → Null device

  • /dev/usb → USB device

This design allows Linux to treat devices like regular files.

/proc - Process and Kernel Information

/proc is a virtual file system. It does not store real files.

It contains runtime system information such as:

  • Running processes

  • CPU usage

  • Memory usage

  • Kernel parameters

Example:

  • /proc/cpuinfo → CPU details

  • /proc/meminfo → Memory status

System monitoring tools use this directory.

/sys - System and Hardware Information

Another virtual file system used for hardware and kernel interaction.

Used by system tools to manage:

  • Devices

  • Drivers

  • Kernel modules

/boot - Boot Loader Files

Contains files required to start the system.

Examples:

  • Kernel image

  • Boot loader (GRUB)

  • Initramfs

If this directory is damaged, system may not boot.

/lib and /lib64 - System Libraries

These contain essential shared libraries used by system programs and kernel modules.

Programs depend on these libraries to run.

/opt - Optional Software

Third-party software and custom applications are often installed here.

Example:

  • Commercial tools

  • External packages

/mnt and /media - Mount Points

Used to mount external storage like:

  • USB drives

  • External disks

  • Network drives

/media is usually for automatic mounting, /mnt for manual mounting.

/run - Runtime System Data

Stores temporary runtime data such as:

  • Process IDs

  • System state

  • Service information

Cleared on reboot.

How Linux File System Works in Real Life

Let us understand with a simple example.

When you open a program:

  1. Command is executed from /bin or /usr/bin

  2. Program loads libraries from /lib or /usr/lib

  3. Reads configuration from /etc

  4. Stores logs in /var/log

  5. Uses /tmp for temporary data

  6. Kernel interacts via /proc and /sys

Every directory has a specific purpose.

Why Linux Uses This Hierarchy

Benefits:

  • Organized structure

  • Predictable system behavior

  • Easy troubleshooting

  • Secure permission model

  • Efficient system management

This structure is defined by FHS (Filesystem Hierarchy Standard).

Linux File Permissions and Ownership

Every file in Linux has:

  • Owner

  • Group

  • Permissions (read, write, execute)

Permissions control access and security across the file system.

Frequently Asked Questions (FAQ)

1. What is Linux file system hierarchy?

It is the structured organization of directories starting from root (/) where every file and system component resides.

2. What is the root directory?

Root (/) is the top-level directory from which all other directories originate.

3. Where are user files stored?

User files are stored inside /home.

4. What is /etc used for?

It stores system configuration files.

5. What is stored in /var?

Logs, cache, mail, and variable system data.

6. What is /proc?

A virtual file system containing process and system runtime information.

7. What is /dev?

Contains device files representing hardware components.

8. What is /boot?

Stores files required to start the Linux system.

9. What is /tmp used for?

Temporary files created by applications.

10. Why is Linux file system important?

It helps manage system organization, security, troubleshooting, and server administration.

Final Thoughts

The Linux File System Hierarchy is simple once understood. Every directory has a clear purpose, and the entire system works in a structured and logical way.

When you know where files live and how Linux organizes its data, system administration, DevOps, and development become much easier and more predictable.

Mastering the Linux file system is a foundational skill for anyone working with Linux-based environments.

To master Linux file system hierarchy and administration with comprehensive training, consider enrolling in our specialized Linux Training program. For those looking to become complete DevOps professionals, we also offer comprehensive DevOps Training that includes Linux fundamentals along with modern DevOps tools and practices.