šŸŽ New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

Understanding Linux Directory Structure: Where Everything Lives and Why

Understanding Linux Directory Structure: Where Everything Lives and Why

The Linux directory structure follows the Filesystem Hierarchy Standard (FHS), which defines a consistent layout across all distributions. Understanding this structure is essential for system administration, troubleshooting, and working efficiently with Linux.

The Root Directory (/)

Everything in Linux starts from the root directory /. Unlike Windows with drive letters (C:, D:), Linux has a single unified tree structure.

Essential Directories

/bin - Essential User Binaries

Contains fundamental commands needed for single-user mode and system recovery: ls, cp, mv, cat, bash. These commands are available to all users.

/sbin - System Binaries

Contains system administration commands typically requiring root: fdisk, iptables, reboot, ifconfig.

/etc - Configuration Files

The central location for system-wide configuration files:

  • /etc/passwd - User account information
  • /etc/fstab - Filesystem mount table
  • /etc/hosts - Static hostname resolution
  • /etc/nginx/ - Nginx web server configuration
  • /etc/ssh/ - SSH server and client configuration
  • /etc/cron.d/ - System cron jobs

/home - User Home Directories

Each user has a personal directory: /home/username. Contains personal files, settings, and user-specific configurations in dotfiles (.bashrc, .ssh/).

/root - Root User Home

The home directory for the root (superuser) account. Kept separate from /home for security and recovery purposes.

/var - Variable Data

Contains data that changes frequently during system operation:

  • /var/log/ - System and application logs
  • /var/www/ - Web server document root
  • /var/lib/ - Application state data (databases, package managers)
  • /var/mail/ - User mailboxes
  • /var/tmp/ - Temporary files preserved between reboots

/tmp - Temporary Files

Temporary files created by programs. Contents may be deleted on reboot. World-writable with sticky bit.

/usr - User Programs

Contains the majority of user applications and utilities:

  • /usr/bin/ - User commands (non-essential)
  • /usr/sbin/ - System commands (non-essential)
  • /usr/lib/ - Libraries for /usr/bin and /usr/sbin
  • /usr/local/ - Locally installed software (compiled from source)
  • /usr/share/ - Architecture-independent data (docs, icons)

/opt - Optional Software

Third-party applications that do not follow the standard hierarchy. Examples: /opt/google/chrome, /opt/lampp.

/proc and /sys - Virtual Filesystems

Not real files on disk — they provide kernel and hardware information:

cat /proc/cpuinfo      # CPU information
cat /proc/meminfo      # Memory information
cat /proc/version      # Kernel version
ls /sys/class/net/     # Network interfaces

/dev - Device Files

Represents hardware devices as files:

  • /dev/sda - First hard drive
  • /dev/null - Discards all data written to it
  • /dev/zero - Provides null bytes
  • /dev/random - Random number generator

/boot - Boot Files

Contains the Linux kernel, initial RAM disk, and bootloader configuration (GRUB).

/mnt and /media - Mount Points

  • /mnt/ - Temporary mount points for manual mounting
  • /media/ - Automatically mounted removable media (USB drives, CDs)

Quick Reference Commands

# Show directory tree
tree -L 1 /

# Find where a command lives
which nginx
type ls

# Check disk usage per directory
du -sh /*

# Find files across the filesystem
find / -name "nginx.conf" 2>/dev/null

Once you understand the Linux directory structure, navigating and managing a Linux system becomes intuitive. Every file has a logical place, and knowing where to look is half of solving any administration challenge.

Share this article:
Dargslan Editorial Team (Dargslan)
About the Author

Dargslan Editorial Team (Dargslan)

Collective of Software Developers, System Administrators, DevOps Engineers, and IT Authors

Dargslan is an independent technology publishing collective formed by experienced software developers, system administrators, and IT specialists.

The Dargslan editorial team works collaboratively to create practical, hands-on technology books focused on real-world use cases. Each publication is developed, reviewed, and...

Programming Languages Linux Administration Web Development Cybersecurity Networking

Stay Updated

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