Top 50 Debugging Commands

These are the commands engineers reach for during incidents: process checks, ports, logs, services, containers, filesystems and network validation.

Debugging Reference

#CommandBrief DescriptionExample
1ps aux | grep javaFind Java processesps aux | grep java
2pgrep -af springFind process by full commandpgrep -af spring
3lsof -i :8080See who is using a portlsof -i :8080
4ss -tulnpList listening ports and ownersss -tulnp
5netstat -tulnpLegacy port listingnetstat -tulnp
6topSee CPU and memory hot spots livetop
7htopFriendlier process monitorhtop
8free -hCheck memory usage quicklyfree -h
9vmstat 1 5CPU, memory, IO overviewvmstat 1 5
10iostat -xz 1 3Disk IO bottlenecksiostat -xz 1 3
11mpstat -P ALL 1 3Per-core CPU viewmpstat -P ALL 1 3
12uptimeCheck load averageuptime
13df -hFilesystem free spacedf -h
14du -sh /var/log/* | sort -hFind large log foldersdu -sh /var/log/* | sort -h
15find /var/log -type f -size +100MFind giant log filesfind /var/log -type f -size +100M
16tail -f app.logLive follow logstail -f app.log
17tail -f app.log | grep ERRORLive error streamtail -f app.log | grep ERROR
18grep -n ERROR app.logFind errors with line numbersgrep -n ERROR app.log
19grep -n 'Exception' big.logFind exceptionsgrep -n 'Exception' big.log
20grep -A 20 -B 5 'Exception' app.logShow context around errorgrep -A 20 -B 5 'Exception' app.log
21awk '/ERROR|WARN/' app.logFilter with awkawk '/ERROR|WARN/' app.log
22sed -n '1000,1050p' app.logPrint line rangesed -n '1000,1050p' app.log
23journalctl -u app -fFollow service logsjournalctl -u app -f
24journalctl -u app --since '1 hour ago'Recent service historyjournalctl -u app --since '1 hour ago'
25systemctl status appService state and recent logssystemctl status app
26systemctl restart appRestart servicesystemctl restart app
27curl -I http://localhost:8080Check HTTP response headerscurl -I http://localhost:8080
28curl -v http://localhost:8080/healthVerbose HTTP checkcurl -v http://localhost:8080/health
29ping -c 4 hostBasic connectivityping -c 4 host
30traceroute hostSee network pathtraceroute host
31nslookup hostBasic DNS checknslookup host
32dig hostDetailed DNS querydig host
33ip addrCheck IP addressesip addr
34ip routeCheck routesip route
35hostname -IQuick host IPhostname -I
36env | sortCheck environment variablesenv | sort
37echo $JAVA_HOMECheck runtime configecho $JAVA_HOME
38which javaCheck Java pathwhich java
39java -versionCheck Java versionjava -version
40ulimit -aCheck process limitsulimit -a
41dmesg | tail -50Kernel-level recent eventsdmesg | tail -50
42find /opt -name '*.jar'Find deployed jarsfind /opt -name '*.jar'
43md5sum app.jarVerify file integritymd5sum app.jar
44stat app.jarVerify size and modify timestat app.jar
45docker psCheck containersdocker ps
46docker logs -f containerFollow container logsdocker logs -f container
47docker inspect containerDetailed container configdocker inspect container
48docker exec -it container shEnter container shelldocker exec -it container sh
49git diffSee config/code changesgit diff
50history | tail -50Recent shell actionshistory | tail -50