I started with ps and top because those are the obvious ones, but the follow-up pushed me toward /proc and that's where I got a bit shaky.
Structure your answer by grouping commands into categories: process overview, resource usage, system calls, and open files/network. For each command, briefly state what it does and the key information it reveals, emphasizing how you'd use it in a real debugging scenario.
Pro tip: Mention that you'd start with `ps` and `top` for a quick overview, then drill down with `strace` or `lsof` only if needed, to avoid performance overhead. This shows you understand the trade-offs between quick checks and deep inspection.
Use `ps -p <PID> -o pid,ppid,user,%cpu,%mem,stat,start,time,cmd` to get basic details like parent PID, user, CPU/memory usage, state, start time, and command. This gives a snapshot without heavy overhead.
Use `top -p <PID>` or `htop -p <PID>` to monitor CPU and memory usage in real time. This helps identify if the process is resource-bound or behaving abnormally.
Use `strace -p <PID>` to trace system calls and signals, which reveals what the process is doing at a low level (e.g., file I/O, network calls). Be cautious: it can slow down the process.
Use `lsof -p <PID>` to list open files, sockets, and pipes. This shows which files and network ports the process is using, useful for diagnosing file descriptor leaks or network issues.
Use `pmap <PID>` for memory mapping, `cat /proc/<PID>/status` for detailed memory and thread info, and `ps -T -p <PID>` to list threads. This helps in diagnosing memory leaks or thread contention.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.