DevOps & Cloud7 September 2026โ€ข18 min readโ€ข1,093 words

Essential Linux Troubleshooting Commands for Production Issues (2026)

Hands-on guide to debugging real-world Linux production issues. CPU spikes, memory leaks, disk I/O bottlenecks, and network socket exhaustion with practical terminal commands.

Abu Thahir

Abu Thahir

Founder & Career Mentor at GetJobWithAbu

When a production alert rings at 2:00 AM saying *"Application server unresponsive, latency exceeding 10 seconds"*, you cannot rely on a GUI. You must SSH into the Linux box and systematically isolate the root cause within minutes.

In my years managing production infrastructure and mentoring DevOps and Application Support engineers, the difference between a junior and senior engineer is troubleshooting methodology.

Here is the systematic methodology and essential command toolkit used by production engineers.

---

The Golden Troubleshooting Flow

Always isolate the resource bottleneck in this order:

  1. CPU: Is the system compute-bound?
  2. Memory: Is the system out of RAM or aggressively swapping?
  3. Disk I/O & Storage: Is disk throughput or IOPS saturated, or are filesystems full?
  4. Network & Sockets: Are sockets exhausted, connections hanging, or packet drops occurring?

---

1. Investigating CPU Spikes

Command 1: uptime & Understanding Load Average

```bash

$ uptime

14:22:01 up 45 days, 3:12, 2 users, load average: 8.52, 4.21, 2.10

```

How to interpret: The three numbers represent load averages over 1, 5, and 15 minutes.

  • Check available cores: nproc
  • If you have a 4-core server and load average is 8.52, your CPU is over-saturated by over 200%. If it is 2.10, the CPU has ample headroom.

Command 2: top / htop

  • Press P in top to sort by CPU usage.
  • Press c to display full command paths.
  • Inspect `%wa` (I/O Wait)! If CPU shows 90% in %wa, the CPU is not busy calculating; it is stalled waiting for disk or network responses.

Command 3: pidstat 1

```bash

$ pidstat 1 5

```

Prints process CPU statistics every 1 second for 5 iterations. Helps identify erratic processes that spike intermittently.

---

2. Investigating Memory Leaks & OOM Killer

Command 1: free -h

```bash

$ free -h

total used free shared buff/cache available

Mem: 15Gi 13Gi 850Mi 120Mi 1.8Gi 1.6Gi

Swap: 2.0Gi 1.8Gi 200Mi

```

Crucial Rule: Look at the `available` column, NOT free. Linux uses spare memory for file buffers and caching (buff/cache), which it can reclaim instantly when applications demand it.

Command 2: Checking if OOM (Out Of Memory) Killer killed your process

```bash

$ dmesg -T | grep -i -E "killed process|oom"

```

If Linux runs completely out of memory and swap, the kernel's OOM Killer will forcibly terminate the process with the highest oom_score (often Java or Node.js).

---

3. Investigating Disk Space & I/O Bottlenecks

Command 1: df -h (Disk Space Exhaustion)

```bash

$ df -h

Filesystem Size Used Avail Use% Mounted on

/dev/nvme0n1p1 50G 49G 1.2G 98% /

```

If disk usage reaches 100%, services like MySQL, Nginx, or Docker will immediately fail to write logs and crash.

Command 2: Finding Largest Directories & Files

```bash

$ du -sh /var/log/* | sort -hr | head -n 10

$ find / -type f -size +500M -exec ls -lh {} + 2>/dev/null

```

Command 3: df -i (Inodes Exhaustion)

Sometimes df -h shows 50% free space, but applications still complain *"No space left on device"*. Check inode usage:

```bash

$ df -i

```

Millions of tiny cache files or session logs can consume all inodes even when gigabytes of disk storage remain free.

Command 4: iostat -xz 1 (I/O Saturation)

```bash

$ iostat -xz 1

```

Look at the `%util` column. If %util is consistently near 100%, your storage disk (EBS/SSD) is at maximum throughput.

---

4. Advanced Process Diagnostics with strace and lsof

When a process appears running in ps but fails to respond to requests, you must inspect its system calls and open file descriptors:

Command 1: strace -p <PID> -f -e trace=file,network

```bash

$ sudo strace -p 14205 -f -e trace=file,network -s 256

```

  • Reveals whether the process is blocked waiting on an unresponsive DNS query, hung on a remote NFS file mount, or attempting to read a locked file descriptor.

Command 2: The "Deleted Open File" Ghost Disk Trap (lsof +L1)

Have you ever deleted a massive 30GB log file using rm, yet df -h still reports 100% disk usage?

```bash

$ sudo lsof +L1

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NLINK NODE NAME

java 18420 root 4w REG 8,1 32212254720 0 1441 /var/log/app.log (deleted)

```

  • Root Cause: In Linux, an inode is only freed when both its directory entry is unlinked and its open file reference count reaches zero. The running Java process still holds the open file descriptor (FD 4w).
  • Emergency Fix Without Restarting Service:

```bash

$ sudo truncate -s 0 /proc/18420/fd/4

```

The disk space is instantly reclaimed by the kernel without terminating the production application.

---

5. Systemd & Journalctl Forensics

```bash

$ sudo journalctl -u nginx.service -n 100 --no-pager

$ sudo journalctl -u my-app.service --since "30 minutes ago" -p err..emerg

$ journalctl --disk-usage

$ sudo journalctl --vacuum-time=2d

```

---

6. Kernel Queues & Context Switching with vmstat

```bash

$ vmstat 1 5

procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----

r b swpd free buff cache si so bi bo in cs us sy id wa st

6 1 0 850120 120500 1840200 0 0 5 80 1200 8500 45 25 28 2 0

```

  • `r` (Run Queue): Number of processes runnable or waiting for CPU runtime. If r consistently exceeds your CPU core count, processes are context-switching heavily.
  • `b` (Blocked Queue): Number of processes in uninterruptible sleep (usually waiting for disk I/O).
  • `cs` (Context Switches): High context switches combined with low user CPU (us) indicates lock contention or excessive thread spawning.
  • `st` (Steal Time): Crucial for AWS EC2 and Azure VMs! If st is above 5%, the cloud hypervisor is starving your virtual machine of CPU cycles due to noisy neighbors.

---

7. Step-by-Step P1 Incident Runbook: "Disk 100% Full"

When a P1 alert fires indicating the root partition is 100% full:

  1. Assess Inodes & Storage:

```bash

df -h /

df -i /

```

  1. Identify Offending Directories:

```bash

sudo du -ahx / | sort -rh | head -n 25

```

  1. Check for Unlinked Open Files:

```bash

sudo lsof +L1

```

  1. Safely Truncate Stale Logs: Never rm an actively written log file. Instead, truncate it:

```bash

sudo truncate -s 0 /var/log/application/error.log

```

  1. Verify Reclaim: Run df -h to verify that free space is immediately restored, then configure /etc/logrotate.d/ to prevent recurrence.
Abu - Founder of GetJobWithAbu

Abu

Founder of GetJobWithAbuCloud & Azure Developer (5+ Years IT Exp)

Cloud & Azure Developer with 5+ years of IT industry experience, having transitioned from a 4.8-year IT Support role into Software & Cloud Development. Dedicated to helping freshers, Tier-2/Tier-3 college graduates, and IT support engineers crack technical interviews through practical production insights, real-world scenario questions, and hands-on guidance.

๐Ÿ“… Last updated: Read Abu's Full Story & Verification Principles โ†’
๐Ÿ“š Recommended Technical Prep

Related Technical Guides & Interview Prep

View All 15+ Guides โ†’

Related Articles