SkillSprout
Chapter 2 · Lesson 12
Advanced
2 min read

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

bash
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

bash
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

bash
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

bash
sudo ss -ltnp
curl -v http://127.0.0.1:8080
sudo ss -tunap
  • -ltnp lists listening TCP processes.
  • curl -v separates DNS, TCP and HTTP failures.
  • ss -tunap shows all TCP/UDP sockets and associated processes.

DNS and route failure

bash
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

bash
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

  1. Reproduce.
  2. Read the direct error.
  3. Identify the failing layer.
  4. Inspect state and logs.
  5. Make the smallest change.
  6. Verify the original symptom.
  7. Document the fix and prevention.

Common Interview Questions

Chapter quiz

Linux Advanced · 6 questions

  1. 1.What exit status usually means success?

  2. 2.Why should cron use absolute paths?

  3. 3.What does `set -u` do?

  4. 4.Which command shows listening TCP processes?

  5. 5.What does `df -i` diagnose?

  6. 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