Guide Linux Beginner

Linux Filesystem

The Filesystem Hierarchy Standard, mount points, filesystem types (ext4, xfs, tmpfs), and how storage devices become directories.

3 min read

What Is the Linux Filesystem?

Unlike Windows (C:\, D:\), Linux has one unified tree rooted at /. Every disk, partition, network share, or virtual filesystem gets mounted onto a directory within that single tree — there’s no concept of separate drive letters.

flowchart TB ROOT["/"] ROOT --> BIN["/bin, /usr/bin — executables"] ROOT --> ETC["/etc — configuration"] ROOT --> VAR["/var — logs, variable data"] ROOT --> HOME["/home — user directories"] ROOT --> TMP["/tmp — temporary files"] ROOT --> PROC["/proc — kernel/process info (virtual)"] ROOT --> DEV["/dev — device files"] ROOT --> MNT["/mnt, /media — mounted external storage"]

The Filesystem Hierarchy Standard (FHS)

PathPurpose
/etcSystem-wide configuration files (never binaries)
/varVariable data: logs (/var/log), spool, databases
/usrUser-installed programs and libraries (most of the OS actually lives here)
/homePer-user home directories
/tmpTemporary files, cleared on reboot (often tmpfs, i.e., RAM)
/optThird-party/optional software packages
/proc, /sysVirtual filesystems exposing kernel/process state — not real files on disk
/devDevice files (/dev/sda, /dev/null, /dev/tty)

Mounting: Turning a Device Into a Directory

# List all mounted filesystems
mount
df -hT

# Mount a device manually
sudo mount /dev/sdb1 /mnt/data

# Persist mounts across reboot
cat /etc/fstab
# UUID=xxxx  /mnt/data  ext4  defaults  0  2

# See disk usage per directory
du -sh /var/log/*

/etc/fstab is read at boot to automatically mount everything — a wrong entry there is one of the classic ways servers fail to boot (“emergency mode”).

Common Filesystem Types

TypeNotes
ext4Most common general-purpose Linux filesystem; journaled, mature, reliable
xfsDefault on RHEL/CentOS; excels with large files and high parallelism
tmpfsRAM-backed, volatile — used for /tmp and /dev/shm for speed
overlayfsUnion filesystem — this is how Docker layers images
nfsNetwork File System — mount a remote directory as if local
# Check filesystem type of a mount
findmnt -T /var
lsblk -f

Everything Is a File

A defining Unix/Linux philosophy: devices, pipes, sockets, and even kernel data structures are exposed as files.

cat /proc/cpuinfo        # CPU info, read from a "virtual" file
cat /proc/meminfo        # Memory info
echo hello > /dev/null   # Discards output — /dev/null is a real device file
cat /proc/1/status       # Info about PID 1 (init/systemd)

Production Considerations

  • A full /var (usually from runaway logs) is one of the most common causes of production outages — monitor disk usage on /var/log specifically.
  • /tmp as tmpfs means anything written there is lost on reboot and counts against RAM — don’t put large persistent files there.
  • Always use UUIDs (not /dev/sdX names) in /etc/fstab — device names can shift between boots, especially with multiple disks.

Quick Interview Answer

“Linux uses a single unified directory tree rooted at /, with disks and partitions mounted onto directories rather than given drive letters. The Filesystem Hierarchy Standard defines conventions — /etc for config, /var for logs, /usr for installed software. /proc and /sys are virtual filesystems exposing live kernel state, not real files on disk.”

Common Mistakes

  • Storing application data in /tmp and being surprised it disappears after a reboot.
  • Referencing /dev/sdb1 directly in /etc/fstab instead of its UUID.
  • Not monitoring /var/log disk usage until the disk is already full and services start failing to write.

Add More Questions to This Guide

Know a question that should be here? Share it and help the community!

Open Google Form