Linux Directory Structure
The Filesystem Hierarchy
Linux organizes everything as files in a single directory tree starting from the root /. Understanding this structure helps you navigate test environments, find configuration files, and locate logs quickly.
/ Root of the filesystem
├── home/user/ Your home directory (~)
├── etc/ Configuration files
├── var/
│ ├── log/ Application and system logs
│ └── lib/ Variable data (databases, packages)
├── tmp/ Temporary files (cleared on reboot)
├── opt/ Optional/third-party software
├── usr/
│ ├── bin/ User-installed binaries
│ └── local/ Locally compiled software
├── proc/ Virtual filesystem (process and kernel info)
├── dev/ Device files
└── srv/ Service data (web servers, FTP)
Directories QA Engineers Use Most
/home/user/ (Your Home Directory, ~)
This is where you work. Your scripts, test configurations, SSH keys, and shell customizations live here.
# Navigate to home directory
cd ~
# Or simply:
cd
# Common QA files in home directory
~/.ssh/config # SSH connection shortcuts
~/.bashrc # Shell customization (aliases, PATH)
~/.npmrc # npm configuration
~/.env # Personal environment variables (not committed)
~/projects/ # Your cloned repositories
/var/log/ (Logs)
This is where you investigate failures. Application logs, system logs, and web server logs all live here.
# Common log locations
/var/log/syslog # System messages
/var/log/auth.log # Authentication events
/var/log/nginx/access.log # Nginx access logs
/var/log/nginx/error.log # Nginx error logs
/var/log/app/application.log # Application-specific logs
/var/log/postgresql/postgresql.log # Database logs
/etc/ (Configuration)
Configuration files for system services and applications. When tests fail due to misconfiguration, this is where you look.
# Common configuration files
/etc/hosts # DNS overrides (useful for test environments)
/etc/nginx/nginx.conf # Nginx web server config
/etc/environment # System-wide environment variables
/etc/postgresql/pg_hba.conf # PostgreSQL access control
/etc/ssl/certs/ # SSL certificates
/tmp/ (Temporary Files)
Temporary data that is cleared on reboot. Useful for staging test data or storing intermediate results.
# Use /tmp for temporary test data
cp test-data.json /tmp/
# Run tests that use /tmp/test-data.json
# On reboot, the file is automatically cleaned up
/proc/ (Virtual Filesystem)
Not real files -- this is a window into the kernel and running processes. Useful for debugging.
# Check system memory
cat /proc/meminfo | head -5
# Check CPU information
cat /proc/cpuinfo | grep "model name" | head -1
# Check a specific process
cat /proc/1234/status | grep -E "(Name|State|VmRSS)"
Navigating the Filesystem
Basic Navigation Commands
# Print current directory
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
cd .. # Go up one level
cd - # Go to previous directory
cd ~/projects # Go to projects in home directory
Finding Files
# Find a file by name (recursive search)
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
Disk Usage
# Disk usage summary
df -h
# Directory size
du -sh /var/log/
# Top 10 largest directories
du -h /var/log/ | sort -rh | head -10
# Check if disk is full (common cause of test failures)
df -h | grep -E "9[0-9]%|100%"
File Operations
# Create directories (including parents)
mkdir -p tests/integration/api
# Copy files
cp source.json destination.json
cp -r tests/ tests-backup/ # Recursive copy
# Move/rename files
mv old-name.ts new-name.ts
mv test-results/ archive/test-results-sprint23/
# Remove files
rm unwanted-file.txt
rm -r old-directory/ # Recursive remove
rm -rf node_modules/ # Force recursive remove (use carefully!)
# Create an empty file
touch new-test.spec.ts
# View file content
cat small-file.txt # Entire file
head -20 large-file.log # First 20 lines
tail -50 large-file.log # Last 50 lines
tail -f /var/log/app.log # Follow file in real-time (live log monitoring)
less large-file.log # Paginated viewer (press q to quit)
Understanding Paths
Absolute vs Relative Paths
# Absolute path: starts from root (/)
/home/qa/projects/webapp/tests/login.spec.ts
# Relative path: relative to current directory
tests/login.spec.ts # If you are in /home/qa/projects/webapp/
../webapp/tests/login.spec.ts # If you are in /home/qa/projects/api/
Special Path Symbols
| Symbol | Meaning | Example |
|---|---|---|
/ |
Root directory | cd / |
~ |
Home directory | cd ~/projects |
. |
Current directory | cp ./config.json /tmp/ |
.. |
Parent directory | cd .. |
- |
Previous directory | cd - |
Hands-On Exercise
- Open a terminal and navigate to
/var/log/. List the files and identify which logs belong to which service. - Find all
.logfiles modified in the last 24 hours anywhere on the system. - Check disk usage on your machine. Which directory is the largest?
- Navigate to your home directory and explore what configuration files (dotfiles) exist.
- Create a directory structure:
~/qa-practice/tests/unit/,~/qa-practice/tests/integration/,~/qa-practice/tests/e2e/ - Use
tail -fto monitor a log file in real-time while performing an action that generates log entries.