Practical Linux exercises and real-world tasks to build your DevOps skills. Each task includes requirements, step-by-step guidance, and solutions. Practice these exercises to prepare for interviews and daily operations.
1. Filesystem Operations Tasks
Practice filesystem operations, file management, and directory manipulation tasks.
Task 1: Log File Management
BeginnerTask Description:
You're managing a server with limited disk space. The /var/log directory is growing too large. Your task is to clean up log files while keeping recent logs for debugging.
Requirements:
- Create a practice directory:
/tmp/log-practice - Generate sample log files with different dates and sizes
- Find and list log files older than 7 days
- Compress logs older than 3 days instead of deleting them
- Delete logs older than 30 days
- Create a script to automate this cleanup
Step-by-Step Implementation:
1 Setup practice environment:
2 Find and list old log files:
3 Compress old logs:
4 Delete very old logs:
5 Create cleanup script:
Complete Solution:
Advanced variations to try:
Task 2: Find and Process Files
IntermediateTask Description:
You need to find specific files across the system and perform operations on them. This is common for security audits, cleanup tasks, or data migration.
Requirements:
- Find all files larger than 100MB in /home directory
- Find all executable files owned by specific users
- Find files modified in the last 24 hours
- Find and delete empty directories
- Find files with specific permissions (world-writable)
- Create a summary report of findings
Practice Setup:
Implementation Tasks:
1 Find large files:
2 Find executable files:
3 Find recently modified files:
4 Find and process empty directories:
5 Find files with specific permissions:
Complete Search Script:
Advanced search patterns:
2. Process & System Management Tasks
Practice process management, system monitoring, and performance optimization tasks.
Task 3: System Monitoring Dashboard
IntermediateTask Description:
Create a system monitoring dashboard script that displays real-time system metrics. This is essential for DevOps engineers to quickly assess system health.
Requirements:
- Display system uptime and load average
- Show CPU usage percentage
- Display memory usage with details
- Show disk usage for all mounted filesystems
- List top 5 processes by CPU and memory
- Show network interface statistics
- Create a continuously updating dashboard
Practice Environment:
Building the Dashboard:
1 Basic system information:
2 CPU and memory metrics:
3 Disk and process information:
4 Network and system load:
5 Continuous monitoring loop:
Advanced Dashboard Features:
Monitoring with alerts:
3. Scripting & Automation Tasks
Practice Bash scripting, automation, and task scheduling exercises.
Task 4: Backup Automation Script
IntermediateChallenge:
Create a comprehensive backup script that automates the backup process for critical directories. The script should include rotation, compression, logging, and error handling.
Requirements:
- Backup multiple directories specified in a config file
- Compress backups using tar and gzip
- Implement backup rotation (keep last N backups)
- Add comprehensive logging
- Include error checking and email notifications
- Make script configurable and reusable
- Test backup restoration process
Building the Backup Script:
1 Setup configuration:
2 Backup function:
3 Rotation and cleanup:
4 Restore function:
5 Main script logic:
Complete Backup System:
Testing the backup system:
Practice Exercises Summary
Complete Task Checklist
| Task | Skills Practiced | Commands Used | Difficulty | Time |
|---|---|---|---|---|
| Log File Management | find, gzip, cron, scripting | find, gzip, tar, cron |
Beginner | 30 min |
| Find and Process Files | find, exec, xargs, file ops | find, exec, ls, du |
Intermediate | 45 min |
| System Monitoring Dashboard | Bash scripting, system metrics | top, free, df, ps |
Intermediate | 60 min |
| Backup Automation Script | Scripting, automation, error handling | tar, gzip, find, cron |
Advanced | 90 min |
| Process Management | Process control, signals, monitoring | ps, top, kill, nice |
Intermediate | 40 min |
| Network Configuration | Networking, firewall, troubleshooting | ip, ss, iptables, netstat |
Advanced | 60 min |
| User Management | User/group management, permissions | useradd, usermod, chmod, chown |
Beginner | 30 min |
| Package Management | Package installation, dependencies | apt, yum, dpkg, rpm |
Beginner | 25 min |
Additional Practice Exercises
Quick practice tasks:
Interview Practice Scenarios
Common interview questions to practice:
Timed practice challenge: