File System Overview

The Linux file system follows the Filesystem Hierarchy Standard (FHS), a set of guidelines that define where files and directories should be located. Unlike Windows, which uses drive letters (C:\, D:\), Linux uses a single unified directory tree rooted at / (called "root"). Every file, device, and resource on the system exists somewhere within this tree.

A key philosophy of Linux is that everything is a file. Regular files, directories, hardware devices, network sockets, and even running processes are represented as files within the filesystem. This unified approach simplifies system management and enables powerful command-line operations.

The Directory Tree

Here is a visual representation of the top-level directory structure:

/
├── bin      Essential user command binaries
├── boot     Boot loader files and kernels
├── dev      Device files
├── etc      System configuration files
├── home     User home directories
├── lib      Essential shared libraries
├── media    Mount point for removable media
├── mnt      Temporary mount point
├── opt      Optional/third-party software
├── proc     Virtual filesystem for process info
├── root     Root user's home directory
├── run      Runtime variable data
├── sbin     Essential system binaries
├── srv      Service data
├── sys      Virtual filesystem for kernel/hardware info
├── tmp      Temporary files
├── usr      User programs and data (read-only)
└── var      Variable data (logs, caches, spools)

Key Directories Explained

/ — Root Directory

The top of the directory hierarchy. Every file and directory on the system exists under this single root. Only the root user has write permission to this directory itself. Do not confuse this with /root, which is the root user's home directory.

/home — User Home Directories

Each regular user gets a personal directory here (e.g., /home/alice). This is where users store their documents, downloads, configuration files, and personal data. The tilde shortcut ~ refers to the current user's home directory. On desktop systems, this is often on a separate partition for easier reinstallation.

/etc — System Configuration

Contains system-wide configuration files in plain text. Examples include /etc/fstab (filesystem mount table), /etc/hostname (machine name), /etc/passwd (user accounts), /etc/ssh/sshd_config (SSH server configuration), and /etc/apt/sources.list (package repositories on Debian-based systems). This is one of the most important directories for system administrators.

/var — Variable Data

Holds data that changes frequently during system operation. Key subdirectories include /var/log (system and application logs), /var/cache (cached data from applications), /var/mail (user mailboxes), and /var/www (default web server document root on many distributions).

/usr — User Programs

Contains the majority of user-installed programs, libraries, and documentation. /usr/bin holds most user commands, /usr/lib contains libraries, /usr/share stores architecture-independent data (icons, documentation), and /usr/local is for software compiled and installed manually by the administrator.

/dev — Device Files

Contains special files that represent hardware devices and virtual devices. For example, /dev/sda represents the first hard disk, /dev/sda1 its first partition, /dev/null discards all data written to it, and /dev/random generates random data. These files let you interact with hardware using standard file operations.

/proc and /sys — Virtual Filesystems

These directories do not exist on disk — they are generated in real-time by the kernel. /proc exposes information about running processes and system state (e.g., /proc/cpuinfo, /proc/meminfo). /sys provides a structured view of hardware devices and kernel subsystems. Both are read-only interfaces to the kernel.

/tmp — Temporary Files

A world-writable directory for temporary files created by applications and users. Contents are typically cleared on every reboot. Do not store anything important here. Many modern distributions mount /tmp as a tmpfs (RAM-based filesystem) for faster access.

/boot — Boot Files

Contains the Linux kernel (vmlinuz), initial RAM disk (initrd or initramfs), and bootloader configuration (GRUB files). On UEFI systems, /boot/efi holds the EFI System Partition contents. This directory is critical for system startup and should not be modified carelessly.

Common Filesystem Types

Linux supports many filesystem formats. The most commonly used ones include:

  • ext4 — The default filesystem for most Linux distributions. Mature, stable, and well-tested with journaling support, extents-based allocation, and backward compatibility with ext2/ext3. Supports volumes up to 1 exbibyte and files up to 16 tebibytes.
  • Btrfs — A modern copy-on-write filesystem with built-in support for snapshots, subvolumes, compression, RAID, and self-healing. Default on Fedora and openSUSE. Excellent for systems that benefit from rollback capabilities.
  • XFS — High-performance journaling filesystem optimized for parallel I/O and large files. Default on Red Hat Enterprise Linux. Excellent for servers handling large datasets.
  • ZFS — A combined filesystem and volume manager with advanced features like data integrity verification, deduplication, and compression. Available on Linux through OpenZFS but not included in the mainline kernel due to licensing.
  • tmpfs — A RAM-based temporary filesystem. Fast but volatile — data is lost on reboot. Used for /tmp, /run, and shared memory.

Mounting and Unmounting

In Linux, storage devices must be mounted (attached to the directory tree) before they can be accessed. The mount point is simply an existing directory where the contents of the device become visible.

# List all mounted filesystems
mount
df -hT

# Mount a USB drive manually
sudo mount /dev/sdb1 /mnt/usb

# Mount with specific options
sudo mount -t ext4 -o rw,noexec /dev/sdb1 /mnt/data

# Unmount a filesystem
sudo umount /mnt/usb

# View the filesystem mount table
cat /etc/fstab

Understanding /etc/fstab

The /etc/fstab file defines which filesystems are automatically mounted at boot time. Each line specifies a device, mount point, filesystem type, mount options, and backup/check settings:

# device            mount-point  type  options         dump  pass
UUID=abc123...      /            ext4  errors=remount-ro  0     1
UUID=def456...      /home        ext4  defaults           0     2
/dev/sda3           none         swap  sw                 0     0
tmpfs               /tmp         tmpfs defaults,noexec    0     0

Disk Usage and Management

# Show disk space usage by filesystem
df -h

# Show disk space with filesystem types
df -hT

# Show directory size
du -sh /var/log

# Show sizes of subdirectories sorted
du -sh /var/* | sort -h

# Find large files (over 100MB)
find / -type f -size +100M -exec ls -lh {} \;

# List block devices
lsblk

# Detailed partition information
sudo fdisk -l

Next Step

Now that you understand the directory structure, learn how Linux controls access to files and directories in our File Permissions guide.