Modern QA2026Navigating the Filesystem
Log inJoin
1 / 2 · Book 19 · The Linux Directory Structure · drill: interview Q&A⊞ allnext →Get the book →

1.3Navigating the Filesystem

Basic Navigation Commands

These are the commands you will type hundreds of times per day. They need to become muscle memory.

# Print current directory (where am I right now?)
pwd

# List files (basic)
ls

# List files with details (permissions, size, date)
ls -la

# List files sorted by modification time (newest first)
ls -lt

# List files with human-readable sizes
ls -lh

# Change directory
cd /var/log       # Go to an absolute path
cd ..             # Go up one level
cd -              # Go to previous directory (toggle between two directories)
cd ~/projects     # Go to projects in home directory

Pro Tip: cd - is incredibly useful when you are switching between two directories. It toggles back and forth like the "last channel" button on a TV remote.

Finding Files

When you know what you are looking for but not where it lives:

# Find a file by name (recursive search from root)
find / -name "playwright.config.ts" 2>/dev/null

# Find files modified in the last 24 hours
find /var/log -mtime -1 -type f

# Find files larger than 100MB (hunt for disk space issues)
find / -size +100M -type f 2>/dev/null

# Find all .spec.ts files in the project
find ~/projects/webapp -name "*.spec.ts" -type f

# Faster alternative: locate (uses a pre-built index)
locate playwright.config.ts

The 2>/dev/null at the end of those commands suppresses "Permission denied" errors that occur when find tries to read directories you do not have access to. You will learn exactly what this syntax means in the Redirection chapter.

Disk Usage

Disk full is a surprisingly common cause of test failures. These commands help you diagnose it:

# Disk usage summary (all mounted filesystems)
df -h

# Directory size
du -sh /var/log/

# Top 10 largest directories
du -h /var/log/ | sort -rh | head -10

# Check if disk is nearly full (common cause of test failures)
df -h | grep -E "9[0-9]%|100%"

Common Mistake: Running du on the root directory (/) without limiting depth will take a very long time and produce enormous output. Always target a specific directory or use du -h --max-depth=1 / to limit the depth.