Troubleshooting Quick Reference

IT Troubleshooting CLI & Log Analysis

When a server goes down or an app stops responding, guessing wastes time. Follow a repeatable read-only triage loop first: gather evidence from network, system resources, and logs before touching anything.

โฑ๏ธ 5 min triage๐ŸŸข Beginner-Friendly๐Ÿ“… Updated: 2026
The 6-Step Troubleshooting Loop (Evidence Before Action)
STEP 1 Identify What broke & who? STEP 2 Check Logs journalctl / syslog STEP 3 Test Layers Net โ†’ RAM โ†’ Disk STEP 4 Isolate Cause Pinpoint root fault STEP 5 Minimal Fix One change at a time STEP 6 Verify & Log Confirm & document If issue persists, return to Step 1 with new evidence

1 Network Connectivity Triage

Work from your machine outward: Local IP โ†’ Gateway/Internet โ†’ Route โ†’ DNS โ†’ HTTP App โ†’ Listening Ports.

ip a Linux (Windows: ipconfig /all)
Check your own IP address & link state
Confirms your network card is UP and actually has an IP address.
๐Ÿ’ก Trick: No IP or 169.254.x.x = DHCP failed, not an internet outage.
ping -c 4 1.1.1.1 Linux/macOS (Win: ping -n 4 1.1.1.1)
Test raw IP reachability (bypasses DNS)
Sends 4 ICMP packets to Cloudflare DNS. Proves whether packets leave your network.
๐Ÿ’ก Trick: ping 1.1.1.1 works but ping google.com fails = DNS is broken.
traceroute 8.8.8.8 Linux/macOS (Windows: tracert 8.8.8.8)
Map every router hop to the destination
Shows the exact hop where packets drop or latency spikes.
๐Ÿ’ก Trick: Stops at hop 1? Your router/firewall is blocking. Stops at hop 8? ISP issue.
dig shekharit.com +short Linux/macOS (Win: nslookup shekharit.com)
Verify DNS name-to-IP resolution
Checks if a domain resolves to the expected IP address cleanly.
๐Ÿ’ก Trick: Test a specific resolver with dig @8.8.8.8 domain.com.
curl -v https://example.com Cross-platform (Linux / macOS / Win11)
Inspect DNS, TLS handshake & HTTP headers
Shows connection steps, SSL certificate errors, redirects, and HTTP status codes (200/502/503).
๐Ÿ’ก Trick: -I fetches headers only; -v reveals where the handshake stalls.
ss -tulpn Linux (Windows: netstat -ano)
List all listening TCP/UDP ports & owning processes
Answers "Is my web server actually listening on port 80/443, and on 0.0.0.0 or only 127.0.0.1?"
๐Ÿ’ก Trick: tcp, udp, listening, process, numeric ("TULPN").

2 System Resource Triage

When a server is slow or crashing, check the four resource pillars in order: CPU, RAM, Disk, and Port Conflicts.

CPU & Load
top / htop
Memory / Swap
free -h
Disk & I/O
df -h / iostat
Port Conflict
lsof -i :80
htop Fallback: top (always installed)
Live CPU, load average & process monitor
Shows which process is pegging CPU cores. Press P for CPU sort, M for RAM sort, q to quit.
๐Ÿ’ก Trick: High wa (I/O wait) means the CPU is idle waiting on a slow disk.
free -h Linux (-h = human-readable)
Check available RAM and Swap usage
Always read the available column, not free (Linux uses free RAM for disk cache).
๐Ÿ’ก Trick: Heavy Swap usage = server is thrashing and will feel frozen.
df -h Disk Free (all mounted filesystems)
Check if any partition is 100% full
A full / or /var partition stops databases, logs, and SSH logins from working.
๐Ÿ’ก Trick: Disk shows space left, but still says "No space"? Run df -i to check inodes.
du -sh * | sort -h Disk Usage (run inside target folder)
Find which folder or file is eating disk space
Summarizes folder sizes in the current directory and sorts largest to the bottom.
๐Ÿ’ก Trick: Run in /var/log firstโ€”runaway logs are the #1 culprit.
iostat -xz 1 5 Package: sysstat
Measure disk read/write saturation (Disk I/O)
Prints 5 snapshots, 1 second apart. Watch %util and await (ms per I/O).
๐Ÿ’ก Trick: %util near 100% = storage bottleneck, not a CPU problem.
sudo lsof -i :80 List Open Files / Network Sockets
Find what process is hogging port 80 (or any port)
Instantly reveals the PID and command name causing "Address already in use".
๐Ÿ’ก Trick: Swap :80 for :443, :3000, or :5432 to check any app port.

3 Log Analysis Quick Commands

Logs tell you why something crashed instead of just that it crashed. Use these four commands to cut straight to errors.

journalctl -p err -b systemd Linux (Ubuntu, RHEL, Debian)
Show only error-level logs from the current boot
-p err filters out noisy info messages; -b limits output to this boot.
๐Ÿ’ก Trick: Check one service live with journalctl -u nginx -f.
tail -f /var/log/syslog RHEL/Alma/Rocky: /var/log/messages
Watch system logs in real time as events happen
Streams new lines to your terminal while you reproduce a bug. Press Ctrl+C to stop.
๐Ÿ’ก Trick: Use tail -n 100 /var/log/syslog to see the last 100 lines immediately.
grep -i error /var/log/syslog Case-insensitive pattern search
Search log files for "error", "ERROR", or "Error"
-i ignores letter case. Add -C 3 to print 3 lines of context before and after each match.
๐Ÿ’ก Trick: Search multiple keywords with grep -iE "error|fail|fatal" file.log.
dmesg -T | tail -n 30 Kernel Ring Buffer
Check kernel & hardware errors with readable timestamps
First place to look for OOM (Out-of-Memory) kills, failing disks, or dropped NIC links.
๐Ÿ’ก Trick: dmesg -T | grep -i "killed process" proves the OOM killer struck.

Quick-Copy Triage One-Liners

journalctl -u nginx --since "15 minutes ago" --no-pager
grep -iE "error|crit|oom" /var/log/syslog | tail -n 25

4 Outage Symptom โ†’ Cause โ†’ First Command

Match the symptom reported by users to the most likely root cause and the exact first command to run.

Symptom Likely Cause First Command to Run
Website down Web service crashed, bad config reload, or upstream proxy returning 502/503. curl -I http://localhost & journalctl -u nginx -n 30
No Internet Missing default gateway, DHCP failure, or broken DNS resolver. ping -c 4 1.1.1.1 (then dig google.com)
Disk 100% full Runaway log file, unrotated container logs, or large temp/backup file. df -h then du -sh /var/log/* | sort -h
Address already in use Another daemon or stale worker process is already bound to that port. sudo lsof -i :80 (or ss -tulpn | grep :80)
Connection refused Target service is stopped, listening only on 127.0.0.1, or wrong port. ss -tulpn & systemctl status <service>

5 The Danger Zone (What NOT To Do)

โš ๏ธ Avoid These 3 Rookie Mistakes During an Outage
1. Rebooting before checking logs

A blind reboot wipes volatile evidence: active network sockets, in-memory process states, and dmesg/tmpfs clues disappearโ€”and the problem often comes right back.

โœ… Safe habit: Spend 60 seconds running journalctl -p err -b and df -h before any reboot.
2. Running kill -9 on databases (PostgreSQL, MySQL, Redis)

kill -9 (SIGKILL) terminates a process instantly without flushing buffers or closing write-ahead logs, risking table corruption and slow crash recovery.

โœ… Safe habit: Use systemctl stop postgresql or kill -15 <PID> (SIGTERM) first so it shuts down cleanly.
3. Deleting an open log file with rm while the app is still writing

If a service holds an open file descriptor to app.log, rm app.log removes the filename, but the disk space stays locked at 100% until you restart the service.

โœ… Safe habit: Truncate the file in place with : > /var/log/app.log (or truncate -s 0 /var/log/app.log) to free disk space immediately.