Linux Troubleshooting Playbook
Overview
Troubleshooting is a sequence of evidence: identify the symptom, reproduce it, isolate the layer, change one variable and verify the result. Linux exposes useful evidence through status, logs, sockets, filesystem tools and kernel diagnostics.
Detailed Notes
Command hangs or exits
Symptom: bash: command not found
command -v program
echo "$PATH"
type -a program
Possible causes include a missing package, PATH not containing the executable or a shell alias.
Permission denied
id
namei -l /path/to/file
ls -ld /path/to
ls -l /path/to/file
namei -l checks every directory component. A parent directory can deny access even if the file mode looks correct.
Disk full
df -h
df -i
sudo du -xh /var 2>/dev/null | sort -h | tail -n 20
Check byte capacity and inode usage. Stop the process creating data if necessary, retain required evidence and rotate or remove known temporary files.
Port conflict or connection failure
sudo ss -ltnp
curl -v http://127.0.0.1:8080
sudo ss -tunap
-ltnplists listening TCP processes.curl -vseparates DNS, TCP and HTTP failures.ss -tunapshows all TCP/UDP sockets and associated processes.
DNS and route failure
getent hosts example.com
ping -c 3 example.com
ip route
If name resolution fails, test DNS. If resolution succeeds but ping fails, test route/firewall. If ping succeeds but HTTPS fails, test TCP port and TLS.
Process exits or service fails
systemctl status service
journalctl -u service --since "15 minutes ago"
ps aux | grep service
Capture the service status and latest logs before restarting. Restarting can erase evidence or create loops.
General order
- Reproduce.
- Read the direct error.
- Identify the failing layer.
- Inspect state and logs.
- Make the smallest change.
- Verify the original symptom.
- Document the fix and prevention.
Common Interview Questions
Chapter quiz
Linux Advanced · 6 questions
1.What exit status usually means success?
2.Why should cron use absolute paths?
3.What does `set -u` do?
4.Which command shows listening TCP processes?
5.What does `df -i` diagnose?
6.What should you inspect before restarting a failed service?
0 of 6 answered
Finished this lesson?
0 of 25 lessons done · 0% of the course

