Top 50 Debugging Commands
These are the commands engineers reach for during incidents: process checks, ports, logs, services, containers, filesystems and network validation. Each row includes a short one-line explanation.
Debugging Reference
| # | Command | Brief Description | Example |
|---|---|---|---|
| 1 | ps aux | grep java | Find Java processes | ps aux | grep java |
| 2 | pgrep -af spring | Find process by full command | pgrep -af spring |
| 3 | lsof -i :8080 | See who is using a port | lsof -i :8080 |
| 4 | ss -tulnp | List listening ports and owners | ss -tulnp |
| 5 | netstat -tulnp | Legacy port listing | netstat -tulnp |
| 6 | top | See CPU and memory hot spots live | top |
| 7 | htop | Friendlier process monitor | htop |
| 8 | free -h | Check memory usage quickly | free -h |
| 9 | vmstat 1 5 | CPU, memory, IO overview | vmstat 1 5 |
| 10 | iostat -xz 1 3 | Disk IO bottlenecks | iostat -xz 1 3 |
| 11 | mpstat -P ALL 1 3 | Per-core CPU view | mpstat -P ALL 1 3 |
| 12 | uptime | Check load average | uptime |
| 13 | df -h | Filesystem free space | df -h |
| 14 | du -sh /var/log/* | sort -h | Find large log folders | du -sh /var/log/* | sort -h |
| 15 | find /var/log -type f -size +100M | Find giant log files | find /var/log -type f -size +100M |
| 16 | tail -f app.log | Live follow logs | tail -f app.log |
| 17 | tail -f app.log | grep ERROR | Live error stream | tail -f app.log | grep ERROR |
| 18 | grep -n ERROR app.log | Find errors with line numbers | grep -n ERROR app.log |
| 19 | grep -n 'Exception' big.log | Find exceptions | grep -n 'Exception' big.log |
| 20 | grep -A 20 -B 5 'Exception' app.log | Show context around error | grep -A 20 -B 5 'Exception' app.log |
| 21 | awk '/ERROR|WARN/' app.log | Filter with awk | awk '/ERROR|WARN/' app.log |
| 22 | sed -n '1000,1050p' app.log | Print line range | sed -n '1000,1050p' app.log |
| 23 | journalctl -u app -f | Follow service logs | journalctl -u app -f |
| 24 | journalctl -u app --since '1 hour ago' | Recent service history | journalctl -u app --since '1 hour ago' |
| 25 | systemctl status app | Service state and recent logs | systemctl status app |
| 26 | systemctl restart app | Restart service | systemctl restart app |
| 27 | curl -I http://localhost:8080 | Check HTTP response headers | curl -I http://localhost:8080 |
| 28 | curl -v http://localhost:8080/health | Verbose HTTP check | curl -v http://localhost:8080/health |
| 29 | ping -c 4 host | Basic connectivity | ping -c 4 host |
| 30 | traceroute host | See network path | traceroute host |
| 31 | nslookup host | Basic DNS check | nslookup host |
| 32 | dig host | Detailed DNS query | dig host |
| 33 | ip addr | Check IP addresses | ip addr |
| 34 | ip route | Check routes | ip route |
| 35 | hostname -I | Quick host IP | hostname -I |
| 36 | env | sort | Check environment variables | env | sort |
| 37 | echo $JAVA_HOME | Check runtime config | echo $JAVA_HOME |
| 38 | which java | Check Java path | which java |
| 39 | java -version | Check Java version | java -version |
| 40 | ulimit -a | Check process limits | ulimit -a |
| 41 | dmesg | tail -50 | Kernel-level recent events | dmesg | tail -50 |
| 42 | find /opt -name '*.jar' | Find deployed jars | find /opt -name '*.jar' |
| 43 | md5sum app.jar | Verify file integrity | md5sum app.jar |
| 44 | stat app.jar | Verify size and modify time | stat app.jar |
| 45 | docker ps | Check containers | docker ps |
| 46 | docker logs -f container | Follow container logs | docker logs -f container |
| 47 | docker inspect container | Detailed container config | docker inspect container |
| 48 | docker exec -it container sh | Enter container shell | docker exec -it container sh |
| 49 | git diff | See config/code changes | git diff |
| 50 | history | tail -50 | Recent shell actions | history | tail -50 |