Crash Investigation — Diagnosing Linux System and Application Failures¶
Crash Investigation is the process of identifying, analyzing, and resolving unexpected failures in Linux systems, applications, services, or the Linux kernel. Crashes can result from software bugs, hardware failures, resource exhaustion, kernel panics, filesystem corruption, or configuration issues. A structured crash investigation helps minimize downtime, identify the root cause, and prevent similar incidents in the future. Every Linux administrator, DevOps engineer, Cloud Architect, Platform Engineer, and Site Reliability Engineer (SRE) should know how to investigate crashes in production environments.
Learning Path¶
Course Progress
What You'll Learn¶
After completing this lesson, you'll be able to:
- Understand Linux system crashes
- Investigate application crashes
- Analyze kernel panics
- Understand core dumps
- Investigate boot failures
- Use crash investigation tools
- Perform root cause analysis
- Apply production incident investigation best practices
Prerequisites¶
Complete:
- Modules 1–11
- Module 12 Lessons 1–8
Why Learn Crash Investigation?¶
Imagine a production application.
Without investigation:
With proper investigation:
Application Crashed
↓
Collect Logs
↓
Analyze Evidence
↓
Find Root Cause
↓
Fix Problem
↓
Stable System
Understanding why a crash occurred is more valuable than simply restarting a service.
What is a Crash?¶
A crash occurs when a system component unexpectedly stops functioning.
Examples:
- Application crash
- Service failure
- Kernel panic
- Operating system crash
- Hardware failure
- Filesystem corruption
Common Causes of Crashes¶
Linux crashes commonly occur because of:
- Memory exhaustion
- Software bugs
- Invalid configuration
- Disk failures
- Hardware faults
- Filesystem corruption
- Driver failures
- Kernel bugs
- Resource exhaustion
Crash Investigation Workflow¶
Crash Occurs
↓
Collect Evidence
↓
Review Logs
↓
Analyze Metrics
↓
Identify Root Cause
↓
Implement Fix
↓
Validate Resolution
Step 1: Check Service Status¶
Example:
Look for:
- Failed state
- Exit code
- Error messages
- Restart attempts
Step 2: Review System Logs¶
Recent logs:
Errors only:
Step 3: Review Kernel Messages¶
Kernel errors:
Step 4: Check Resource Usage¶
CPU:
Memory:
Disk:
Storage I/O:
Step 5: Check for OOM Events¶
Applications may terminate when the Linux Out of Memory (OOM) Killer runs.
Search kernel logs.
Or:
Example:
Step 6: Check Application Logs¶
Most applications maintain dedicated log files.
Examples:
Application logs often provide more detail than system logs.
Kernel Panic¶
A kernel panic occurs when the Linux kernel encounters an unrecoverable error.
Example:
Common causes:
- Faulty drivers
- Hardware failures
- Kernel bugs
- Corrupted memory
- Filesystem corruption
Boot Failure Investigation¶
Review previous boot logs.
Current boot:
Core Dumps¶
A core dump is a snapshot of an application's memory at the time of a crash.
It helps developers analyze:
- Call stack
- Variables
- Threads
- Memory state
Enable Core Dumps¶
Check the current limit.
Enable core dumps.
Analyze Core Dumps¶
Common tool:
Example:
Useful commands inside GDB:
Review Service Restart History¶
Look for:
Check Filesystem Health¶
For ext4:
Only run on an unmounted filesystem or in maintenance mode.
Check Disk Health¶
Detects hardware issues.
Network-Related Crashes¶
Verify connectivity.
Listening ports.
Common Commands¶
System logs.
Kernel messages.
Service status.
Memory.
Core dumps.
Real Production Examples¶
Check previous boot.
View kernel errors.
Check OOM events.
Verify service status.
Production Perspective¶
Crash investigation is critical for:
- Cloud infrastructure
- Kubernetes clusters
- Database servers
- Enterprise Linux
- API services
- Web servers
- Financial systems
- High-availability platforms
A structured investigation reduces Mean Time to Resolution (MTTR) and improves system reliability.
Hands-on Lab¶
Task 1¶
Check the status of a system service.
or
Task 2¶
Review the latest system logs.
Task 3¶
Display kernel errors.
Task 4¶
Search for OOM events.
Task 5¶
Check memory usage.
Task 6¶
Review the previous boot logs.
Task 7¶
Check whether core dumps are enabled.
Task 8¶
Create a crash investigation report that includes:
- Service status
- System logs
- Kernel messages
- Memory usage
- Disk usage
- CPU usage
- OOM events
- Root cause
- Resolution steps
Command Deep Dive¶
| Command | Purpose | Production Example |
|---|---|---|
journalctl | Review system logs | Incident investigation |
dmesg | View kernel messages | Hardware diagnostics |
systemctl status | Check service health | Service troubleshooting |
free -h | Review memory usage | OOM investigation |
gdb | Analyze core dumps | Application debugging |
journalctl -b -1 | Review previous boot | Boot failure analysis |
Common Crash Investigation Mistakes¶
| Mistake | Solution |
|---|---|
| Restarting services immediately | Collect logs first |
| Ignoring kernel messages | Review dmesg and kernel journal |
| Deleting logs before analysis | Preserve evidence |
| Investigating only one component | Review CPU, memory, disk, network, and applications |
| Fixing symptoms instead of the root cause | Perform structured root cause analysis |
Production Troubleshooting Scenario¶
Scenario
A production Java application crashes repeatedly.
Investigation:
Shows repeated failures.
Next:
Application logs show:
Further investigation:
Available memory is nearly exhausted.
Kernel logs:
Confirm the OOM Killer terminated the Java process.
Resolution:
- Increase application heap size appropriately.
- Optimize memory usage.
- Add system memory if required.
- Configure monitoring and alerts for memory pressure.
The application remains stable after remediation.
Best Practices¶
- Preserve logs before restarting services.
- Investigate both system and application logs.
- Collect CPU, memory, disk, and network metrics.
- Review previous boot logs after system crashes.
- Enable core dumps for critical applications when appropriate.
- Document investigation findings and corrective actions.
- Perform post-incident reviews to prevent recurrence.
- Automate monitoring and alerting for critical resources.
Common Mistakes¶
❌ Restarting systems before collecting evidence.
✅ Avoid this mistake: restarting systems before collecting evidence.
❌ Ignoring application logs.
✅ Always review application logs.
❌ Never checking kernel messages.
✅ Always checking kernel messages.
❌ Assuming every crash has the same cause.
✅ Verify every crash has the same cause instead of assuming it.
❌ Failing to document investigation results.
✅ Avoid this mistake: failing to document investigation results.
Interview Questions¶
Beginner¶
- What is a crash investigation?
- What is a kernel panic?
- Which command displays kernel messages?
- How do you review previous boot logs?
Intermediate¶
- How would you investigate a repeatedly crashing Linux service?
- What is a core dump?
- How do you identify an OOM event?
- Which logs should be reviewed during an application crash?
Architect Level¶
- How would you build an enterprise incident response workflow for Linux crashes?
- How would you reduce MTTR during production incidents?
- How would you combine monitoring, logging, and core dump analysis to improve reliability?
Summary¶
In this lesson, you learned:
- Crash investigation fundamentals
- Service failure analysis
- Kernel panic investigation
- Core dumps
- Boot failure analysis
- OOM investigation
- Root cause analysis
- Production incident response best practices
Crash investigation is a critical operational skill for Linux administrators. By systematically collecting evidence, reviewing logs, analyzing system resources, and identifying the root cause, administrators can restore services quickly, prevent recurring failures, and improve the reliability of production environments.
Key Takeaways¶
- Always collect evidence before restarting services.
- Review both system and application logs.
- Investigate kernel messages and OOM events.
- Use core dumps for application crash analysis.
- Perform structured root cause analysis.
- Document findings and preventive actions after every significant incident.
What's Next?¶
Monitoring Best Practices — Building Reliable Linux Monitoring Strategies
You'll explore:
- Building an effective monitoring strategy
- Selecting key performance indicators (KPIs)
- Configuring alerts and thresholds
- Centralized monitoring
- Monitoring dashboards
- Capacity planning
- Production monitoring best practices
By the end of the lesson, you'll understand how to design a comprehensive monitoring strategy that improves system reliability, reduces downtime, and supports proactive operations in production Linux environments.