DEV Community

Naval Kishor Upadhyay
Naval Kishor Upadhyay

Posted on

Linux Filesystem Explained — From `/` to `/home` (and Everything Between)

When you first explore a Linux system, the directories may seem cryptic:

/bin, /etc, /usr, /var … what do they mean, and why are they there?

The truth is: the Linux filesystem is not random. It’s carefully structured, following the Filesystem Hierarchy Standard (FHS). Once you see the logic, it becomes predictable and powerful.

This guide takes you step by step through the Linux directory tree, explaining what each folder contains, why it exists, and how to explore it.


1. The Root / — the Starting Point

  • At the very top is the root directory (/).
  • Every file and folder in Linux grows from this one root, like branches of a tree.

📂 Example:

/home/alex/report.txt
Enter fullscreen mode Exit fullscreen mode
  • / → root (the trunk)
  • home → branch
  • alex → smaller branch
  • report.txt → the leaf (file)

Unlike Windows, Linux does not use C:\ or D:\. Disks and USB drives are mounted into this tree.

Try this:

ls /
Enter fullscreen mode Exit fullscreen mode

2. System Essentials

These directories allow Linux to start and run, even before you log in.

/bin — Basic Commands

  • Stores essential tools always available.
  • Examples: ls, cp, mv, cat.
ls /bin | head
Enter fullscreen mode Exit fullscreen mode

/sbin — System Commands

  • Utilities for system administration.
  • Examples: ip, mount, shutdown.

/lib — Shared Libraries

  • Libraries needed by /bin and /sbin programs.
  • Without these, commands won’t work.

/boot — Startup Files

  • Holds files needed to boot Linux:
    • Kernel (vmlinuz)
    • Bootloader (GRUB)

/etc — System Configuration

  • Contains configuration files.
  • Examples:
    • /etc/passwd → user accounts
    • /etc/hosts → hostname mappings
cat /etc/hostname
Enter fullscreen mode Exit fullscreen mode

3. Programs and Applications

/usr — Program Files

  • Houses the bulk of installed software.
  • Key subdirectories:
    • /usr/bin → executables
    • /usr/share → docs, icons, locales

/usr/local — Locally Installed Software

  • For software compiled or installed by the administrator.
  • Keeps it separate from system-installed programs.

/opt — Optional Applications

  • Self-contained third-party software.
  • Example: /opt/google/chrome.

4. User Data

/home — User Directories

  • Each user has their own space.
  • Example: /home/alex/ → personal files and configs.

/root — Administrator’s Home

  • The root user’s home directory.
  • Kept separate from /home so it’s always accessible.

5. Variable Data

/var — Logs and State

  • Contains files that change during operation.
  • Examples:
    • /var/log/ → log files
    • /var/lib/ → databases
    • /var/cache/ → cached files
ls /var/log
Enter fullscreen mode Exit fullscreen mode

/tmp — Temporary Files

  • Used by programs for short-lived data.
  • Cleared on reboot.

/var/tmp — Longer Temporary Storage

  • Similar to /tmp, but files may survive reboots.

6. Devices and System Information

/dev — Devices as Files

  • Hardware appears as files.
  • Examples:
    • /dev/sda → first hard disk
    • /dev/tty → terminal
    • /dev/null → discards data
ls /dev | head
Enter fullscreen mode Exit fullscreen mode

/proc — Process and Kernel Info

  • Virtual files representing system state.
  • Examples:
    • /proc/cpuinfo → CPU info
    • /proc/meminfo → memory usage
cat /proc/cpuinfo | head
Enter fullscreen mode Exit fullscreen mode

/sys — Device and Kernel Settings

  • Exposes kernel and device details.
  • Example: /sys/class/net/ shows network interfaces.

7. Mount Points

/mnt — Manual Mounts

  • Used for temporary, admin-controlled mounts.
sudo mount /dev/sdb1 /mnt
Enter fullscreen mode Exit fullscreen mode

/media — Removable Media

  • Where USBs and external drives appear automatically.
  • Example: /media/alex/MyUSB/.

8. Other Directories

  • /srv → Data for services (web, FTP, etc.)
  • /run → Runtime info about processes and sockets (cleared at reboot)
  • /lost+found → Recovered files after filesystem checks
  • /snap, /flatpak → Application packaging (distro-specific)

9. Key Takeaways

  • / is the single starting point of the filesystem.
  • System essentials live in /bin, /sbin, /lib, /boot.
  • Configurations are in /etc.
  • Applications go into /usr, /usr/local, /opt.
  • User files are stored in /home/<username>.
  • Logs and caches go into /var, while temp data is in /tmp.
  • Hardware and system info appear in /dev, /proc, /sys.
  • Mount points for external storage are /media and /mnt.

Once you know this structure, navigating Linux feels much more natural, and you’ll always know where to look for programs, configurations, logs, or personal data.

Top comments (0)