>
← Back to Linux

Linux File System Hierarchy Explained: Every Directory Demystified

The Linux file system follows a standardized hierarchy defined by the Filesystem Hierarchy Standard (FHS). Understanding this structure is crucial for system administration, troubleshooting, and effective Linux usage. Every directory serves a specific purpose, and knowing which files live where makes you a more confident Linux operator.

What Is the Linux File System Hierarchy?

The Linux file system hierarchy is a standardized directory structure that organizes system files, user files, and configuration data. Unlike Windows, which uses drive letters (C:, D:), Linux uses a single root directory (/) from which all other directories branch. This unified approach creates a consistent, predictable layout across all Linux distributions.

The FHS standard ensures that applications, users, and administrators know exactly where to find or place files. When you understand this hierarchy, navigating any Linux system becomes intuitive, and you'll waste less time hunting for configuration files or binaries.

The Root Directory and Top-Level Structure

Everything in Linux starts with the root directory (/). This isn't a user's home folder—it's the filesystem root that contains all other directories and files. When you boot into Linux, the kernel mounts the root filesystem, and from there, other filesystems (like /home or /var) can be mounted.

Here's what you'll find when you run ls / on most Linux systems:

Directory Purpose
/bin Essential command binaries (ls, grep, cat)
/sbin System binaries for root only (fsck, reboot)
/boot Bootloader and kernel files
/dev Device files (hard drives, terminals)
/etc Configuration files for system and apps
/home User home directories
/lib Essential shared libraries and modules
/media Mount points for removable media
/mnt Temporary mount points for filesystems
/opt Optional software packages
/proc Virtual filesystem with system process info
/root Root user's home directory
/run Runtime data for running processes
/srv Data for services provided by system
/sys Virtual filesystem with kernel/hardware info
/tmp Temporary files (cleared on reboot)
/usr User programs, libraries, documentation
/var Variable data (logs, caches, mail)

Critical System Directories

/bin and /sbin: Essential Executables

/bin contains critical command binaries that must be available even in single-user mode. Think of these as your toolkit: ls, grep, cat, cp, mv, and bash itself. These commands are needed for basic system operation and repair.

/sbin (system binaries) contains programs that typically require root privileges. This includes fsck (filesystem checker), reboot, shutdown, ifconfig, and iptables. Regular users can still see what's here, but they can't execute these programs without elevated permissions.

In modern systems like Ubuntu or Fedora, /bin, /sbin, /lib, and /lib64 are often symlinked to their counterparts in /usr for simplicity. But you'll still interact with them as if they're separate directories.

/etc: Configuration Central

/etc is where system and application configuration files live. This directory is the nerve center of Linux administration. You'll spend considerable time here editing files with vim or nano.

Common files you'll encounter:

When you install a service or application, its configuration file usually lands in /etc or a subdirectory like /etc/nginx or /etc/mysql.

/home and /root: User Spaces

/home is where regular user accounts store their personal files. Each user gets a directory: /home/alice, /home/bob, and so on. Inside each home directory, you'll find personal files, configurations, and the hidden .bashrc and .ssh directories.

/root is the home directory for the root (administrator) user. It's separate from /home because root needs a home directory accessible even if /home isn't mounted.

When you log in, your shell sets the $HOME environment variable to your home directory. The tilde (~) is shorthand for your home directory:

cd ~
# Equivalent to:
cd /home/yourusername

/var: Variable Data

/var stores data that changes frequently during normal operation. This includes:

When troubleshooting, /var/log is your first stop. System logs live in /var/log/syslog (Debian/Ubuntu) or /var/log/messages (RedHat/CentOS), and application-specific logs appear in subdirectories like /var/log/nginx or /var/log/mysql.

Development and User Software Directories

/usr: User Programs and Libraries

/usr contains most user-installed applications and their libraries. The name is historical and misleading—it doesn't mean "user" files, but rather "Unix System Resources." This is a major directory with several important subdirectories:

When you install Python via your package manager, it goes to /usr/bin/python. When you compile something from source and run make install, it typically lands in /usr/local/bin. This separation prevents locally-compiled software from overwriting system packages.

/opt: Optional Software

/opt is for third-party software that doesn't follow standard Unix conventions. Large commercial applications or custom software bundles often install here. For example, you might find /opt/firefox or /opt/myapp/.

/srv: Service Data

/srv holds data for services provided by the system. A web server might store website files in /srv/www, or a FTP server might use /srv/ftp. This keeps service data separate from user data.

System and Kernel Directories

/boot: Kernel and Bootloader

/boot contains everything needed to boot your system: the bootloader (GRUB) configuration, the Linux kernel, and initrd (initial ramdisk) images. You'll typically see files like vmlinuz-5.15.0 (the kernel) and initrd.img-5.15.0 (the initial ramdisk).

This directory must be accessible before the main filesystem is mounted, which is why it's often on a separate partition. When upgrading your kernel, /boot is where new kernel files land.

/dev: Device Files

/dev contains device files that represent hardware devices and pseudo-devices. These aren't regular files—they're special files that act as interfaces to drivers.

Common device files: