Skip to main content

Command Palette

Search for a command to run...

Linux Filesystem Hierarchy Explained: A Beginner-to-Advanced Guide

Updated
11 min readView as Markdown
Linux Filesystem Hierarchy Explained: A Beginner-to-Advanced Guide

If you have just installed Linux, booted up your machine, opened the terminal, and typed ls /, you were probably met with a wall of cryptic two- and three-letter folder names: bin, etc, usr, var, opt.

If you are coming from Windows, your first question is likely: "Where is my C: drive? And what are all these strange folders?"

Don't worry—you are not alone. Many computer science students and engineers navigate Linux for years without truly understanding why these directories are named this way or how they work under the hood.

In this blog, we will break down the Linux Filesystem Hierarchy Standard (FHS), clear up common myths, learn how to navigate the directory tree, and understand the design ideas behind it. The FHS is a convention, not a rigid law: distributions can add directories, merge old paths, or package applications in different ways. The examples below describe a typical modern Linux installation.


1. The Forest of Slashes: Windows vs. Linux

One of the biggest differences between Windows and Linux is how they organize the filesystem namespace.

  • Windows uses a drive-based system. Your operating system lives on C:. If you plug in a USB drive, it gets assigned a new letter like D: or E:.

  • Linux uses a single unified tree structure. There are no drive letters. Instead, everything starts from a single point called the root directory, represented by a single forward slash (/).

The Linux filesystem is one unified directory tree rooted at /.

Think of the root / as the trunk of a massive tree. Every accessible file is reached somewhere below it. Separate filesystems—such as another disk, a USB drive, or a network share—can be attached at directories in that tree using mounts. After mounting, the contents of that filesystem appear at the chosen directory (the mount point), so the application does not need a separate drive letter. If the mount point already contained files, they are temporarily hidden until the filesystem is unmounted.

Windows exposes separate drive letters whereas Linux attaches filesystems into one namespace through mount points.


2. The Golden Rule: "Everything Is a File"

If you remember only one thing from this blog, make it this design principle: In Linux, almost everything is exposed through file-like interfaces.

Rather than giving every part of the system a completely different interface, Linux lets programs use familiar paths and operations for many tasks:

  • Regular files: Your code, PDFs, images, and text documents.

  • Directories: Special filesystem objects that map names to other filesystem objects.

  • Devices: Many hardware and pseudo-devices are exposed through device files, such as storage devices under /dev and input devices like /dev/input/event0.

  • Processes: Information about running programs is exposed through virtual files under /proc.

This is a powerful convention, not a literal rule: sockets, pipes, and system calls are also important interfaces, and not every resource behaves like an ordinary file.

Why is this useful?

It often lets you use familiar command-line tools such as cat, grep, and echo to inspect or interact with system interfaces as well as ordinary files. The operations supported by a particular interface still matter—writing to a device or kernel interface is not the same as editing a text file.

  • Want to see your computer's CPU specifications? Just read a virtual file: cat /proc/cpuinfo.

  • Want to see your available RAM? Just check: cat /proc/meminfo.

Important: /proc and /sys are interfaces, not ordinary folders full of permanent files. Some entries are generated when you read them, and many are only meaningful on a running Linux kernel.


3. Grouping Directories by Purpose

Rather than memorizing folders alphabetically, it is much easier to group them by what they do:

📂 User Workspaces

  • /home (The Workspace): This is where regular users store their personal files, projects, and downloads. If your username is Alice, your personal folder is /home/alice. Think of it as your desktop and documents folder.

  • /root (The Administrator's Home): This is the private home directory of the system administrator (the root user). Crucial distinction: / is the starting point of the entire filesystem, while /root is just one specific folder inside it. A regular user may have administrative power through sudo without using /root as their home directory.

📂 The Toolbox & Applications

  • /bin & /sbin (Essential Tools): Traditionally, /bin held essential commands usable by ordinary users (ls, cat, cp, rm), while /sbin held essential system-administration commands (ip, mount, fsck, and sometimes shutdown). The s means system or superuser, but it does not mean that every system-related program must be in /sbin, nor that only root can execute its files. On many modern distributions both are compatibility links into /usr/bin and /usr/sbin as part of a merged-/usr layout.

  • /usr (Most installed software): Despite its historical name, /usr is not the same as a user's home directory. It commonly holds the bulk of installed programs, shared libraries, documentation, and shared data—for example, under /usr/bin, /usr/lib, and /usr/share. A package-installed application such as Firefox may place its executable in /usr/bin, libraries in /usr/lib, and desktop metadata in /usr/share/applications. Google Chrome's .deb package commonly keeps the application files under /opt/google/chrome while placing a launcher or symlink in /usr/bin.

  • /lib & /lib64 (Shared Libraries): These hold libraries needed by essential programs and, on some systems, the dynamic loader. As with /bin, they may be compatibility links to locations under /usr on a merged-/usr system.

  • /usr/local (Administrator-installed local software): Software installed manually by the system administrator traditionally goes here, such as /usr/local/bin and /usr/local/lib. It is intended to remain separate from files managed by the distribution's package manager.

  • /opt (Self-contained optional applications): Large or third-party applications that keep their files together may be installed under /opt, for example /opt/vendor-app. There is no universal “X folder” for applications: the location depends on the packaging method.

  • Per-user applications: A user can install programs without affecting the whole system, commonly under ~/.local/bin and ~/.local/share. Snap and Flatpak applications use their own layouts (often /snap and /var/lib/flatpak). These are conventions, not replacements for learning /usr.

A useful rule of thumb is:

Installation style Common locations
Distribution package (apt, dnf, pacman) /usr/bin, /usr/lib, /usr/share, with configuration in /etc and changing data in /var
Manually installed administrator software /usr/local/bin, /usr/local/lib, or /opt/<application>
Per-user software ~/.local/bin, ~/.local/lib, and ~/.local/share
Snap or Flatpak Their package-specific locations and runtime namespaces

The exact layout can vary. To find the files owned by a package, use the package manager rather than guessing—for example, dpkg -L firefox on Debian/Ubuntu or rpm -ql firefox on Fedora-based systems.

📂 The Settings & Variable Data

  • /etc (System Configuration): Historically, the name came from "et cetera," . Today, /etc conventionally contains host-specific, system-wide configuration, such as service, network, and account-related settings.

  • /var (Variable Data): Short for variable. Unlike mostly static program files, /var holds data that changes during normal operation—often logs (/var/log), caches, mail queues, spool files, and application state.

📂 Runtime, Temporary, and Kernel Interfaces

  • /run (Runtime State): This holds volatile state created since boot, such as PID files, sockets, and runtime service data. It is typically mounted as tmpfs, so its contents normally disappear when the system shuts down or reboots.

  • /tmp (Temporary Scratchpad): Applications use this for temporary workspace files. It may be disk-backed or mounted as tmpfs; cleanup timing and whether contents survive a reboot depend on the distribution and system configuration. Do not use it for data you need to keep.

  • /dev (Device Interfaces): This is where device files and pseudo-devices are exposed.

  • /proc & /sys (Kernel Interfaces): These are virtual filesystems provided by the kernel rather than ordinary files stored on disk. /proc exposes process and kernel information; /sys exposes devices, drivers, and other kernel objects.

  • /boot (Boot files): Contains files needed to boot Linux, such as the kernel and initramfs. Some systems use a separate filesystem mounted here.

  • /mnt and /media (Mount points): /mnt is a conventional temporary mount point for an administrator; /media is commonly used for removable media mounted for a desktop user.

  • /srv (Service data): A conventional location for data served by services, such as a website or file server.

/lost+found (Filesystem recovery): On many ext filesystems, this directory holds recovered fragments after filesystem repair. It may not exist on other filesystem types.

The major Linux directories grouped by purpose.


4. Crucial Navigational Shortcuts

To explore this tree yourself in the terminal, you only need a few simple commands:

  • pwd (Print Working Directory): Tells you exactly where you are in the tree.

  • cd (Change Directory): Moves you to another folder.

    • cd ~ takes you straight back to your safe and cozy home directory.

    • cd .. moves you up one level (closer to the / root).

  • ls: Lists the contents of the directory you are in.

  • ls -la: Includes hidden entries (names beginning with .), permissions, owners, sizes, and timestamps.

  • man <command> or <command> --help: Reads local documentation and usage options.

  • which <command> or command -v <command>: Shows which executable the shell would run. Use type -a <command> to also see aliases and all matching entries in PATH.

Paths, PATH, and permissions

A path beginning with / is absolute: /etc/hosts means the same thing no matter where you are. A path without that slash is relative to the current directory: notes/today.md. . means the current directory and .. means its parent; ~ is expanded by the shell to the current user's home directory.

When you type chrome, the shell searches the directories in the PATH environment variable, usually including /usr/local/bin, /usr/bin, and possibly ~/.local/bin. The directory where a program is stored and the permissions needed to run it are separate concerns. A binary in /usr/bin is not automatically “for root,” and a binary in /usr/sbin is not automatically inaccessible to regular users.

Linux also uses ownership and permission bits on filesystem objects. Inspect them with ls -l; use sudo only when an operation genuinely requires elevated privileges, and take extra care with commands that modify /etc, /usr, or /var.

Pro-Tip: Visualizing the Tree

You can install a tool called tree using your package manager (like sudo apt install tree on Ubuntu). Running the following command will print a level-1 overview of the directories visible below /:

tree -L 1 /

tree may not be installed, and some directories will produce permission warnings. A portable alternative is:

findmnt                 # show mounted filesystems and mount points
ls -ld / /home /usr /var # inspect selected directories

5. A Few Advanced Checks

The visible directory tree is a namespace assembled from multiple filesystems. These commands help connect paths to storage and programs:

df -h /home              # filesystem containing /home and its free space
du -sh ~/Downloads       # space used by one directory
findmnt /                # filesystem mounted at the root
readlink -f "$(command -v ls)"  # resolve a symlink to its target
file /usr/bin/ls         # identify a file's type

Do not assume that every directory consumes space on the root disk: /home, /boot, /var, or even /tmp may be separate mounts. Likewise, /proc, /sys, and often /run are virtual or memory-backed filesystems rather than permanent disk storage.


Summary Cheat Sheet

Directory What Lives Here?
/ The root start of the filesystem tree.
/home Personal folders for regular users.
/etc System configurations and settings.
/bin Traditionally, essential commands such as ls and cat; often a link into /usr/bin today.
/sbin Traditionally, essential system-administration commands; often a link into /usr/sbin today.
/usr Distribution-managed programs, libraries, and shared data.
/usr/local Locally installed administrator-managed software.
/opt Optional or third-party self-contained applications.
/var Variable files that change, such as logs.
/run Volatile runtime state, typically stored in tmpfs.
/tmp Temporary application files; cleanup behavior is system-dependent.

Linux from the Ground Up

Part 1 of 1

A practical Linux series covering the filesystem, shell, permissions, processes, networking, services, storage, troubleshooting, and system internals. Each article starts with beginner-friendly explanations and gradually connects the concepts to real-world DevOps, cloud, containers, and Kubernetes usage.