Chapter 16: Detective Mode

Chapter 16: Troubleshooting

System Investigation

journalctl -xe
journalctl -u service -n 50
journalctl -p err --since today
tail -f /var/log/syslog
tail -f /var/log/nginx/error.log

Disk and Memory

df -h
du -sh /* 2>/dev/null | sort -hr
free -h
cat /proc/meminfo

Network Issues

ping gateway
curl -v https://site.com
ss -tuln | grep :80
traceroute 8.8.8.8

Process Issues

ps aux | grep Z
lsof -i :80
lsof -p PID

Troubleshooting Methodology

  1. Define the problem clearly
  2. Gather information (logs, metrics)
  3. Form a hypothesis
  4. Test one change at a time
  5. Document what you did
  • Check logs first, always
  • Isolate the layer: hardware, OS, service, app