Linux Process Management: A Visual Guide

Learn to view, control, and killing processes in Linux using ps, top, htop, kill, and systemctl. Master process states, signals, and service management.

Linux Process Management: A Visual Guide
📧

Get weekly IT guides

Join 5,000+ IT professionals

Subscribe Free

Your server is slow. Something is eating 98% of your CPU. Do you know how to find the culprit and stop it — right now?

Introduction

Every program running on your Linux machine is a process. Your web server is a process. Your text editor is a process. Even the terminal you’re typing in is a process. Understanding how to view, monitor, and control processes is one of the most practical skills you can have as a Linux user.

What You'll Learn
  • How to see every process running on your system
  • How to read and understand process states (R, S, T, Z)
  • How to kill and pause processes using signals
  • How to manage system services with systemctl
  • How to spot and fix a runaway process
Mental Model: The Office Building

Think of your Linux system as a busy office building:

  • Processes are the employees — each doing a specific job.
  • The CPU is the single conference room — only one employee uses it at a time.
  • The OS scheduler is the meeting organizer — it decides who gets the room next.
  • killing a process is firing an employee — they leave immediately.

What is a Process?

When you run a command like nginx or python3 app.py, Linux creates a process — a running instance of that program. Each process gets:

  • A unique PID (Process ID — a number like 1042)
  • A parent PID (PPID — the process that launched it)
  • Its own chunk of memory and CPU time
  • A current state (Running? Sleeping? Dead?)
Linux process states: Running, Sleeping, Stopped, Zombie, Dead
Every process moves through these states during its lifetime.

The 4 Process States You Must Know

StateCodeMeaning
RunningRActively using the CPU right now
SleepingSWaiting for something (disk, network, timer)
StoppedTPaused with Ctrl+Z or SIGSTOP
ZombieZFinished but parent hasn’t cleaned it up yet

Viewing Processes

ps — The Process Snapshot

ps gives you a snapshot of processes at this moment.

ps aux

Show all processes from all users with details

beginner
Annotated ps aux output showing USER, PID, %CPU, %MEM, and STAT columns
Reading ps aux output — each column tells you something important.
The Two Most Useful ps Commands
  • ps aux — Show everything from all users
  • ps aux | grep nginx — Find a specific process by name

top — The Live Process Monitor

ps is a snapshot. top is a live feed — it updates every few seconds.

top

Live process monitor — press Q to quit

beginner

Key controls inside top:

KeyAction
qQuit
kKill a process (type PID when prompted)
MSort by memory usage
PSort by CPU usage
1Show individual CPU cores
htop — top's Better-Looking Cousin

Install htop for a color-coded, mouse-friendly version of top.

sudo apt install htop then just type htop.

Finding a Specific Process

pgrep nginx

Get PID of nginx without grep

beginner
pidof sshd

Get PID of sshd

beginner
ps aux | grep python3

Find python3 processes

beginner

Controlling Processes

The kill Command (Sending Signals)

“kill” is a misleading name. kill actually sends a signal to a process. Most signals are not “kill” commands.

kill 1042

Send SIGTERM (polite stop) to PID 1042

beginner
kill -9 1042

Send SIGKILL (force stop) to PID 1042

beginner
killall nginx

Kill all processes named nginx

beginner
pkill python3

Kill all python3 processes by name

beginner

The 3 Signals You’ll Use Most:

SignalNumberNameEffect
Default15SIGTERM”Please clean up and exit.” — Polite
Force9SIGKILL”Exit NOW.” — Cannot be ignored
Pause19SIGSTOP”Pause.” — Resume with SIGCONT
SIGKILL is a Last Resort

Always try kill PID (SIGTERM) first. It lets the process save data and close files cleanly. kill -9 forces immediate termination — data may be lost.

Background and Foreground Jobs

When you’re in a terminal, you can run processes in the background:

ping google.com &

Run ping in background (&)

beginner
jobs

List background jobs in current terminal

beginner
fg 1

Bring job 1 back to foreground

beginner
bg 1

Resume a stopped job in background

beginner

Ctrl+Z stops the current foreground process (moves it to Stopped/T state). Ctrl+C sends SIGINT to terminate it.


Managing System Services with systemctl

Services (or daemons) are background processes that start at boot and keep running — like your web server, SSH server, or database.

systemctl is the command to control them.

systemctl service lifecycle diagram
systemctl wraps start/stop/restart/enable/disable around any service.
systemctl status nginx

Check if nginx is running and its last logs

beginner
sudo systemctl start nginx

Start nginx right now

beginner
sudo systemctl stop nginx

Stop nginx right now

beginner
sudo systemctl restart nginx

Restart nginx (stop + start)

beginner
sudo systemctl reload nginx

Reload config without restarting

beginner
sudo systemctl enable nginx

Make nginx start automatically on boot

beginner
sudo systemctl disable nginx

Stop nginx from starting on boot

beginner
start vs enable — Critical Difference
  • start = turn on right now
  • enable = turn on at next boot

To run a service permanently: you need bothenable AND start.


Troubleshooting: Finding the Process Eating Your CPU

This is the real-world scenario you’ll face. Here’s the exact workflow:

Step 1 — Find the offender:

ps aux --sort=-%cpu | head -10

Show top 10 CPU-hungry processes

beginner

Step 2 — Confirm it’s the culprit:

top -p 3841

Watch a specific PID in real time

beginner

Step 3 — Try to stop it politely:

kill 3841

Send SIGTERM (polite)

beginner

Step 4 — If it doesn’t stop, force it:

kill -9 3841

Send SIGKILL (force)

beginner

Step 5 — Find out what it was:

journalctl -u nginx --since '10 min ago'

Check service logs

beginner

Hands-On Challenge

Try these steps on your own Linux machine (or a VM):

  1. Open a terminal and run sleep 300 & — this starts a harmless 5-minute background process.
  2. Run ps aux | grep sleep — find its PID.
  3. Run kill <PID> — stop it politely.
  4. Verify it’s gone: run ps aux | grep sleep again.
  5. Bonus: Run sudo systemctl status ssh and read its output.

Key Takeaways

  • Every running program is a process with a unique PID and a current state (R/S/T/Z).
  • ps aux gives a snapshot; top and htop give a live view.
  • kill PID sends SIGTERM (polite). kill -9 PID forces termination.
  • Use systemctl for services — remember: start = now, enable = on boot.
  • Sort ps by --sort=-%cpu to instantly find runaway processes.
🧠

Test Your Knowledge

Take a quick 4-question quiz to check your understanding.

📧

Get weekly IT guides

Join 5,000+ IT professionals

Subscribe Free
Type to start searching...