Process & Performance Management
Module 6 · Processes, Kernel & Hardware

Process & Performance Management

ps, top, kill signals, nice/renice priority, and the process states you need to recognize when something on a Linux box is misbehaving.

Viewing Processes

Every running program gets a unique PID (Process ID) the moment it starts.

TaskCommand
Snapshot of currently running processesps aux (BSD-style) or ps -ef (UNIX-style)
Live, auto-refreshing view — sort/prioritize/kill processes interactivelytop
A friendlier, color-coded, mouse-scrollable version of tophtop (not installed by default everywhere — install it before you need it)
Find the PID(s) of a process by namepgrep processname
List every file a process currently has openlsof (or lsof -p PID for one specific process)
Show how long the system has been running and its load averageuptime
View CPU model, cores, and flagscat /proc/cpuinfo
Generate historical system-activity reports (CPU, memory, I/O over time)sar
Retrieve performance statistics for the boot process itselfsystemd-analyze (add blame to rank the slowest-starting units)

The Five Process States

StateMeaning
Running (R)Actively executing on the CPU, or ready to run and waiting its turn
Sleeping / interruptible (S)Waiting on an event (input, a timer, a lock) — can be woken by a signal
Uninterruptible sleep (D)Waiting on I/O (usually disk) and cannot be interrupted by a signal, not even SIGKILL, until the I/O completes
Stopped (T)Execution paused, typically by a job-control signal (Ctrl+Z) or by the debugger
Zombie (Z)The process has finished executing, but its parent hasn’t yet collected its exit status — it lingers as an entry in the process table only
⚠️ Common Pitfall: You Can't Kill a Zombie

A zombie process is already dead — there’s no running program left to signal. What actually needs fixing is the parent process, which hasn’t called wait() to reap the zombie’s exit status. If a system accumulates zombies, the real fix is restarting or patching the parent process, not trying (and failing) to kill -9 the zombie’s PID directly.


Sending Signals: Terminating and Controlling Processes

A signal determines how a targeted process should respond — most commonly, but not exclusively, to end it.

SignalNumberEffect
SIGHUP1Hangup — traditionally “reload configuration” for daemons
SIGINT2Interrupt — what Ctrl+C sends
SIGKILL9Force-terminate immediately — cannot be caught, blocked, or ignored by the process
SIGTERM15Politely ask the process to terminate (the default signal for kill) — the process can catch this and clean up first
SIGSTOP19Pause the process — cannot be caught or ignored
SIGCONT18Resume a stopped process
CommandEffect
kill PIDSend SIGTERM (default) to a specific PID
kill -9 PID or kill -SIGKILL PIDForce-terminate a specific PID
killall processnameSend a signal to every process matching a name
pkill -f patternSend a signal to every process matching a pattern, including the full command line
⚠️ Common Pitfall: Always Try SIGTERM Before SIGKILL

SIGTERM gives a process the chance to close files, flush buffers, and shut down cleanly. SIGKILL gives it no chance at all — the kernel just removes it, which can leave corrupted files or orphaned locks behind. Reach for -9 only after a plain kill has failed to end the process.


Priority: nice and renice

Every process has a nice value from -20 (highest scheduling priority) to 19 (lowest) that influences how much CPU time the scheduler gives it relative to other processes.

TaskCommand
Start a new process with a specific (non-default) nice valuenice -n 10 somecommand
Change the nice value of an already-running processrenice -n 5 -p PID
Keep a process running after its terminal/session closesnohup somecommand & (redirects hangup signals and detaches output to nohup.out)
⚠️ Common Pitfall: Lower Nice Value = Higher Priority (Counterintuitive!)

A process with nice value -20 is the most aggressive about grabbing CPU time; a process with nice value 19 is the most willing to yield. “Nice” describes how considerate the process is being toward everything else on the system — a low number means it isn’t being very nice at all. Only root can set a negative nice value.


🧠 Knowledge Check

1. A process shows state Z in ps output and won't respond to kill -9. What's actually wrong?

2. Which signal should you send first when trying to stop a misbehaving process cleanly?

3. You set a background job's nice value to -15. What does that do to its scheduling priority?


What’s Next

Processes compete for more than CPU time — Lesson 2 covers how the kernel manages memory and what to check when a system starts thrashing.