🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

Linux Directory Structure Explained: Complete Filesystem Guide (2026)

Linux Directory Structure Explained: Complete Filesystem Guide (2026)

Understanding the Linux directory structure is fundamental to becoming a proficient Linux user and administrator. Unlike Windows, where the filesystem is organized around drive letters (C:, D:), Linux uses a single hierarchical tree starting from the root directory /. Every file and directory in the entire system branches from this single point.

This guide explains every major directory in the Linux Filesystem Hierarchy Standard (FHS) with practical examples showing what each directory contains and when you would interact with it.

The Filesystem Hierarchy Standard (FHS)

The FHS is a standard maintained by the Linux Foundation that defines the directory structure and contents for Unix-like operating systems. All major Linux distributions follow this standard, meaning the knowledge you gain here applies to Ubuntu, Fedora, AlmaLinux, Debian, and more.

/ (Root Directory)

The top-level directory from which all other directories branch. Only the root user typically has write access directly to /. Think of it as the trunk of the filesystem tree.

/bin — Essential User Binaries

# Contains commands needed for single-user mode and system repair
  # Available to ALL users

  ls /bin/
  # Key commands found here:
  # ls, cp, mv, rm, cat, grep, echo, bash, chmod, chown, mkdir, rmdir

  # Modern distributions often symlink /bin to /usr/bin
  ls -la /bin
  # /bin -> usr/bin  (on Ubuntu 20.04+, Fedora, etc.)

  # Check where a command lives
  which ls          # /usr/bin/ls
  which bash        # /usr/bin/bash

/sbin — System Administration Binaries

# Commands for system administration (usually require root/sudo)
  ls /sbin/
  # Key commands: fdisk, fsck, iptables, reboot, shutdown, ifconfig, mkfs
  # Used for disk partitioning, filesystem repair, network configuration

  # Often symlinked to /usr/sbin on modern systems
  ls -la /sbin

/etc — System Configuration Files

# THE most important directory for system administrators
  # ALL system-wide configuration lives here (etc = "editable text configuration")

  # Identity and naming
  cat /etc/hostname           # System hostname
  cat /etc/hosts              # Local DNS mappings (IP to hostname)
  cat /etc/os-release         # Distribution name and version
  cat /etc/machine-id         # Unique system identifier

  # User and authentication
  cat /etc/passwd             # User account definitions
  sudo cat /etc/shadow        # Encrypted passwords (root only!)
  cat /etc/group              # Group definitions
  cat /etc/sudoers            # Sudo access rules (edit with visudo)

  # Network
  cat /etc/resolv.conf        # DNS resolver configuration
  cat /etc/network/interfaces # Network interface config (Debian)
  ls /etc/NetworkManager/     # NetworkManager config (RHEL/Fedora)

  # Services
  cat /etc/ssh/sshd_config    # SSH server configuration
  ls /etc/nginx/              # Nginx web server config
  ls /etc/apache2/            # Apache web server config
  ls /etc/postgresql/         # PostgreSQL config

  # Package management
  ls /etc/apt/                # APT config and repos (Debian/Ubuntu)
  ls /etc/yum.repos.d/        # DNF/YUM repos (RHEL/Fedora)

  # System startup
  cat /etc/fstab              # Filesystem mount table (mounted at boot)
  cat /etc/crontab            # System-wide cron jobs

/home — User Home Directories

# Each regular user gets a directory here
  ls /home/
  # /home/john/
  # /home/sarah/
  # /home/devops/

  # A typical home directory contains:
  ls -la ~/
  # .bashrc          — Bash shell configuration
  # .profile         — Login shell configuration
  # .bash_history    — Command history
  # .ssh/            — SSH keys and known_hosts
  # .config/         — Application configs (XDG standard)
  # .local/          — User-specific data and binaries
  # Desktop/         — Desktop files
  # Documents/       — User documents
  # Downloads/       — Downloaded files
  # .cache/          — Application caches

  # The ~ shortcut always refers to current user's home
  echo ~         # /home/john
  echo ~sarah    # /home/sarah

/root — Root User Home

# Home directory for the root (superuser) account
  # Kept SEPARATE from /home for security reasons
  # If /home is on a separate partition that fails to mount,
  # root can still log in and fix things

  sudo ls -la /root/

/var — Variable Data Files

# Files that grow and change during normal system operation
  # This directory is often on its own partition

  # Logs (most important for troubleshooting!)
  ls /var/log/
  /var/log/syslog         # General system log (Debian/Ubuntu)
  /var/log/messages       # General system log (RHEL/CentOS)
  /var/log/auth.log       # Authentication events (login, sudo, SSH)
  /var/log/kern.log       # Kernel messages
  /var/log/nginx/         # Nginx access.log and error.log
  /var/log/apache2/       # Apache logs
  /var/log/postgresql/    # PostgreSQL logs

  # Web content
  /var/www/               # Default web server document root
  /var/www/html/          # Default Nginx/Apache web root

  # Application state and databases
  /var/lib/               # Application state data
  /var/lib/postgresql/    # PostgreSQL database files
  /var/lib/mysql/         # MySQL database files
  /var/lib/docker/        # Docker images, containers, volumes
  /var/lib/apt/           # APT package cache

  # Temporary and cache
  /var/cache/             # Application caches (apt, man, etc.)
  /var/tmp/               # Temporary files that PERSIST across reboots

  # Mail and queues
  /var/mail/              # User mailboxes
  /var/spool/             # Queued items (print jobs, mail, cron)

/tmp — Temporary Files

# Temporary files - typically cleared on reboot
  # World-writable (anyone can create files here)
  # Programs use this for scratch space

  ls /tmp/

  # Security best practice: mount /tmp as tmpfs with restrictions
  # In /etc/fstab:
  # tmpfs /tmp tmpfs defaults,noexec,nosuid,nodev,size=2G 0 0
  # noexec = cannot execute programs from /tmp (prevents many attacks)

/usr — User Programs (Secondary Hierarchy)

# Contains the majority of installed software
  # Often the largest directory on the system
  # Usually mounted read-only in production

  /usr/bin/          # Most user commands (installed packages end up here)
  /usr/sbin/         # System administration commands (non-essential)
  /usr/lib/          # Libraries for programs in /usr/bin and /usr/sbin
  /usr/lib64/        # 64-bit libraries (on multilib systems)
  /usr/local/        # LOCALLY compiled/installed software (not from packages)
  /usr/local/bin/    # Local binaries (custom scripts, manually installed tools)
  /usr/share/        # Architecture-independent (shared) data
  /usr/share/man/    # Manual pages
  /usr/share/doc/    # Package documentation
  /usr/share/zoneinfo/ # Timezone data
  /usr/include/      # C/C++ header files for development

  # /usr/local is YOUR space for custom software
  # Package managers don't touch /usr/local

/opt — Optional/Third-Party Software

# Self-contained third-party applications
  # Each package gets its own subdirectory: /opt/vendor/package

  ls /opt/
  # /opt/google/chrome/       — Google Chrome
  # /opt/containerd/          — Container runtime
  # /opt/lampp/               — XAMPP stack
  # /opt/jetbrains/           — JetBrains IDEs

  # Convention: /opt/companyname/productname/

/dev — Device Files

# Everything in Linux is a file - including hardware devices
  # Device files are created dynamically by the kernel (udev)

  /dev/sda           # First SATA/SCSI hard disk
  /dev/sda1          # First partition on first disk
  /dev/sdb           # Second hard disk
  /dev/nvme0n1       # First NVMe SSD
  /dev/null          # Black hole - discards everything written to it
  /dev/zero          # Infinite stream of zero bytes
  /dev/random        # Cryptographically secure random data
  /dev/urandom       # Non-blocking random data
  /dev/tty           # Current terminal
  /dev/loop0         # Loop devices (for mounting disk images)

  # Practical uses:
  echo "test" > /dev/null    # Discard output
  dd if=/dev/zero of=test.img bs=1M count=100  # Create 100MB empty file
  dd if=/dev/urandom bs=32 count=1 | base64    # Generate random token

/proc — Process and Kernel Information

# Virtual filesystem - files don't exist on disk
  # Generated by the kernel in real-time
  # Essential for system monitoring and debugging

  cat /proc/cpuinfo        # CPU details (model, cores, speed)
  cat /proc/meminfo        # Memory usage details
  cat /proc/version        # Kernel version string
  cat /proc/uptime         # System uptime in seconds
  cat /proc/loadavg        # CPU load averages (1, 5, 15 min)
  cat /proc/partitions     # Disk partitions
  cat /proc/mounts         # Currently mounted filesystems

  # Process-specific information (replace PID with actual process ID)
  ls /proc/1/              # Process 1 (systemd/init)
  cat /proc/1/cmdline      # Command that started the process
  cat /proc/1/status       # Process status and memory
  ls -l /proc/1/fd/        # Open file descriptors
  cat /proc/self/status    # Info about the current process

/sys — Kernel and Hardware Information

# Another virtual filesystem for kernel subsystem info
  # Used to interact with kernel parameters and hardware

  ls /sys/class/net/                  # Network interfaces
  cat /sys/class/net/eth0/address     # Network MAC address
  cat /sys/class/net/eth0/speed       # Link speed in Mbps
  ls /sys/block/                      # Block devices (disks)
  cat /sys/class/thermal/thermal_zone0/temp  # CPU temperature

/boot — Boot Loader Files

# Contains everything needed to boot the system
  # Usually a separate small partition (512MB - 1GB)

  ls /boot/
  # vmlinuz-*        — Compressed Linux kernel
  # initrd.img-*     — Initial RAM disk (loads drivers before root is mounted)
  # config-*         — Kernel build configuration
  # System.map-*     — Kernel symbol table
  # grub/            — GRUB bootloader configuration

  # WARNING: Be very careful editing files here
  # Corrupting /boot can make your system unbootable

/mnt and /media — Mount Points

# /mnt  = Temporary mount point (manual admin use)
  # /media = Auto-mounted removable media (USB drives, CDs)

  # Manually mount a USB drive
  sudo mount /dev/sdb1 /mnt
  ls /mnt/
  sudo umount /mnt

  # Auto-mounted USB appears here
  ls /media/username/USB-DRIVE-NAME/

  # Mount a network share
  sudo mount -t nfs server:/share /mnt/nfs
  sudo mount -t cifs //server/share /mnt/smb -o username=user

Quick Reference Summary

DirectoryPurposeKey Contents
/binEssential commandsls, cp, mv, bash
/sbinAdmin commandsfdisk, iptables, reboot
/etcConfigurationpasswd, ssh, nginx, fstab
/homeUser data.bashrc, .ssh, Documents
/rootRoot homeAdmin user files
/varVariable datalogs, www, lib, cache
/tmpTemporary filesCleared on reboot
/usrUser programsbin, lib, share, local
/optThird-party appsChrome, IDEs
/devDevice filessda, null, random
/procProcess infocpuinfo, meminfo
/sysSystem infoHardware, kernel params
/bootBoot filesvmlinuz, initrd, grub
/mntManual mountsAdmin mount point
/mediaRemovable mediaUSB, CD auto-mount

Recommended Reading

Build a solid Linux foundation:

Download our Linux Directory Structure Cheat Sheet for a printable wall reference showing every directory and its contents.

Share this article:
Dorian Thorne
About the Author

Dorian Thorne

Cloud Infrastructure, Cloud Architecture, Infrastructure Automation, Technical Documentation

Dorian Thorne is a cloud infrastructure specialist and technical author focused on the design, deployment, and operation of scalable cloud-based systems.

He has extensive experience working with cloud platforms and modern infrastructure practices, including virtualized environments, cloud networking, identity and acces...

Cloud Computing Cloud Networking Identity and Access Management Infrastructure as Code System Reliability

Stay Updated

Subscribe to our newsletter for the latest tutorials, tips, and exclusive offers.