Linux Directory Structure

Every Linux system has the same basic directory structure. Once you learn it, you can navigate any Linux system - Ubuntu, CentOS, Debian, Arch - they all follow the same layout.

The Filesystem Hierarchy Standard (FHS)

Linux follows the FHS - a standard that defines where files should go. Let's explore the key directories.

Terminal
$ls /
bin dev home lib64 mnt proc run srv tmp var boot etc lib media opt root sbin sys usr

The Essential Directories

/ (Root)

The top of the tree. Everything is under this.

/home - User Home Directories

Where users live:

/home/
├── alice/
├── bob/
└── charlie/

Each user gets their own directory. Your stuff is in /home/yourusername.

Root User Exception

The root user's home is /root, not /home/root. This is intentional - even if /home fails to mount, root can still log in.

/etc - Configuration Files

System-wide configs live here:

Terminal
$ls /etc
apt crontab fstab hosts nginx passwd ssh sudoers ...

Key files:

  • /etc/passwd - User accounts
  • /etc/hosts - Local DNS overrides
  • /etc/ssh/ - SSH server config
  • /etc/nginx/ - Nginx config (if installed)

"etc" stands for "et cetera" but think of it as "editable text config."

/var - Variable Data

Files that change frequently:

/var/
├── log/     # System logs
├── www/     # Web server files (on some systems)
├── lib/     # Application data
└── cache/   # Cached data
Terminal
$ls /var/log
auth.log dpkg.log nginx/ syslog kern.log

When you need logs, check /var/log.

/tmp - Temporary Files

Scratch space that gets cleared on reboot:

Terminal
$ls /tmp
tmp.ABC123 tmp.XYZ789 ...

Don't Store Important Data Here

/tmp gets wiped on reboot. Never put anything important here.

/usr - User Programs

Read-only user data. Most programs live here:

/usr/
├── bin/      # User commands (ls, grep, etc.)
├── lib/      # Libraries
├── local/    # Locally installed software
└── share/    # Shared data (docs, icons, etc.)

/bin and /sbin - System Binaries

Essential commands:

  • /bin - Basic user commands (ls, cp, mv)
  • /sbin - System administration commands (fsck, iptables)

Modern Linux

Many modern distributions merge /bin with /usr/bin and /sbin with /usr/sbin. You'll see them as symbolic links.

/dev - Device Files

Hardware represented as files:

Terminal
$ls /dev | head
disk/ null random sda sda1 sda2 stderr stdin stdout tty urandom zero
  • /dev/sda - First hard drive
  • /dev/null - Black hole (discards everything)
  • /dev/random - Random number generator

/proc - Process Information

Virtual filesystem with system info:

Terminal
$cat /proc/cpuinfo | head -5
processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 142 model name : Intel Core i7

/opt - Optional Software

Third-party applications:

/opt/
├── google/
│   └── chrome/
├── slack/
└── zoom/

/mnt and /media - Mount Points

Where external drives appear:

  • /mnt - Temporary mounts (manual)
  • /media - Removable media (USB drives, CDs)

Quick Reference

DirectoryPurpose
/Root of everything
/homeUser home directories
/etcConfiguration files
/varVariable data (logs, caches)
/tmpTemporary files
/usrUser programs
/bin, /sbinEssential binaries
/devDevice files
/procProcess/system info
/optOptional/third-party software
/mnt, /mediaMount points
Knowledge Check

Where would you look for system log files?

Key Takeaways

  • All Linux systems follow the same basic structure
  • /etc = configs, /var = variable data, /home = users
  • /var/log is your go-to for troubleshooting
  • /tmp gets wiped on reboot - don't trust it
  • /proc lets you inspect the running system
  • Understanding this structure helps on any Linux system

Next: the time-saving magic of tab completion.