Skip to main content
senior
advanced
Linux

Linux Process Debugging

Question

A process is consuming 100% CPU on a Linux server. Walk me through how you would identify and troubleshoot this issue.

Answer

Start with top or htop to identify the process. Use ps aux to get details. Check strace to see system calls, lsof for open files, and /proc/<pid>/ for process info. For Java/Python, get thread dumps. Check logs, and consider perf or flamegraphs for deep analysis. May indicate infinite loops, memory leaks, or resource contention.

Why This Matters

Systematic troubleshooting is essential for production issues. Starting with broad tools (top) and narrowing down (strace, perf) helps identify root causes efficiently. Understanding Linux process management and debugging tools is a core DevOps skill.

Code Examples

Identify high CPU process

bash

Deep process analysis

bash
Common Mistakes
  • Immediately killing the process without investigating the root cause
  • Not checking if the high CPU is expected (batch job, build process)
  • Forgetting to check system logs before diving into process-level debugging
Follow-up Questions
Interviewers often ask these as follow-up questions
  • How would you generate a thread dump for a Java application?
  • What is the difference between CPU user time and system time?
  • How do you identify if the issue is I/O bound vs CPU bound?
Tags
linux
troubleshooting
debugging
performance
sysadmin