Mastering Linux Filesystem Hierarchy: Where Every Directory Belongs
This guide demystifies the Linux filesystem hierarchy by explaining the purpose of each top‑level directory—such as /bin, /etc, /home, /var, and /usr—and shows where different types of files should be stored for a clean, well‑organized system.
Imagine staring at a confusing maze of Linux directory names and wondering where specific file types belong. You might have tossed files into /usr/share hoping it was correct, only to discover later that /var/local was the proper place. This article decodes the meaning of each top‑level directory and tells you the appropriate locations for common file types.
/bin
This is the primary location for essential executable binaries required by the system during boot. Basic commands like ls and top reside here, and if /usr/bin is unavailable during startup, /bin may be used as a fallback symlink.
/boot
The /boot directory holds all critical files needed to start the operating system, including the kernel, bootloader files (e.g., GRUB), and EFI files for modern UEFI systems. Problems here can render the system unbootable.
/dev
/dev(short for “device”) contains references to most attached devices—both physical and virtual—such as hard drives, USB peripherals, virtual terminals, and null devices. Any device you interact with from the command line typically appears in this directory.
/etc
/etcstores all core configuration files for the system and installed programs. It is the place to modify program behavior, network settings, or crontab entries.
/home
This directory contains each user’s personal home directory (e.g., /home/username). Users store personal files—documents, music, pictures, or source code—here, but should not place shared program configurations or system‑wide data.
/lib, /lib32, /lib64, …
These directories hold shared C libraries and kernel modules required by the binaries in /bin. If multiple architectures are supported, you will see corresponding lib directories (e.g., lib32).
/lost+found
This simple directory contains files that were damaged but recovered after events like power loss or hardware failure.
/media
Used as a mount point for removable media such as CDs, USB flash drives, or ISO images. Historically it also held floppy and Zip drives.
/mnt
A generic mount point for attaching external disks, NFS shares, or other remote filesystems. It is empty by default, allowing you to decide what to mount there.
/opt
Short for “optional”, this directory was originally intended for add‑on software packages that are not part of the base distribution. Many distributions still use it for third‑party packages and their static configuration files.
/proc
A virtual filesystem that provides a window into kernel information. Its “files” are not real files but expose metrics about processes, memory, and other subsystems. Reading them yields data similar to what many binaries report.
/root
The home directory of the root user. When logged in as root, the home directory is /root rather than /home/root, providing a fallback if /home becomes inaccessible.
/run
Stores runtime information such as PID files, lock files, and socket information. It is meant for temporary data needed while the system is running, not for persistent storage.
/sbin
Similar to /bin, but contains binaries intended for system administration tasks (e.g., fdisk, usermod). These tools have elevated privileges for modifying the OS.
/srv
Used to hold data served by the system, such as web server files (HTML, images) when the machine provides services.
/sys
Present on some distributions, /sys mirrors /proc but presents device and kernel information in a more structured format.
/tmp
A directory for temporary files. Anything placed here may disappear after a reboot, making it suitable for non‑essential data or intermediate output.
/usr
According to the Linux Foundation’s Filesystem Hierarchy Standard (FHS), /usr contains “shared, read‑only data”. In practice it stores architecture‑independent files, such as /usr/share and user‑installed binaries in /usr/local/bin. It is often mounted read‑only on other systems.
/var
The “variable” directory holds data that changes during system operation. Typical contents include:
Printer spools
Lock files
Package manager caches (e.g., Debian apt)
E‑mail data
Log files
It is also the place for /var/local, a catch‑all for miscellaneous configuration files that don’t fit elsewhere.
Summary
The Linux filesystem hierarchy is a complex but well‑structured system. Understanding the purpose of each top‑level directory makes file placement intuitive and deepens your knowledge of how Linux operates at a fundamental level.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
