DevOps Journey
Linux

File Structure

Linux filesystem hierarchy and organization

File Structure

The Linux filesystem follows a hierarchical structure starting from the root directory (/).

Filesystem Hierarchy Standard (FHS)

Root Directory (/)

The top-level directory containing all other directories and files.

Important Directories

System Directories:

  • /bin - Essential user command binaries (ls, cat, cp, etc.)
  • /sbin - System administration commands (reboot, shutdown, etc.)
  • /lib - System libraries required by binaries
  • /lib64 - 64-bit system libraries
  • /etc - System configuration files (passwd, hostname, etc.)
  • /sys - System and process information
  • /proc - Process and system information

Boot and Kernel:

  • /boot - Boot loader files and kernel images
  • /root - Root user's home directory

User Data:

  • /home - User home directories
  • /tmp - Temporary files (cleared on reboot)
  • /var - Variable data (logs, caches, mail, etc.)
  • /opt - Optional application software

Additional:

  • /usr - User programs and data (/usr/bin, /usr/lib, /usr/local)
  • /srv - Service-specific data
  • /dev - Device files (hardware)
  • /mnt - Mount points for filesystems
  • /media - Mount points for removable media
# Print working directory
pwd

# Change directory
cd /home
cd .. # parent directory
cd ~ # home directory

# List directory contents
ls -la # detailed listing
ls -l /etc # list specific directory

# Tree view
tree /home

Understanding Paths

Absolute Paths start with /:

/home/user/documents/file.txt

Relative Paths are relative to current directory:

documents/file.txt
../other-dir/file.txt

Best Practices

  • Store user data in /home
  • Configuration files go in /etc
  • Application logs go in /var/log
  • Temporary files belong in /tmp
  • Never delete critical system directories

On this page