Linux Processes Explained: ps, top, and kill in Action


Your Linux machine is never idle. Behind that quiet desktop or blinking cursor, dozens — usually hundreds — of processes are running: system services, your browser, background daemons, updaters. A process is just a running program with its own memory, its own ID, and its own slice of CPU time. Understanding processes is what separates a Linux beginner from a Linux user who actually knows what’s happening.

Seeing Processes: ps

The ps command takes a snapshot of what’s running right now. The two forms you’ll use most:

ps aux

This shows every process on the system: the user running it, its process ID (PID), how much CPU and memory it uses, and the command that started it. Piping it through grep finds specific programs:

ps aux | grep firefox

For a tree view showing which process started which, use:

ps -ef --forest

Great for tracing a program back to its parent.

Watching Live: top and htop

ps is a snapshot; top is a live feed. Run it and you’ll see processes updating in real time, sorted by CPU usage. The top section shows overall CPU, memory, and swap — your system’s vital signs.

Key presses inside top:

  • k — kill a process (it asks for the PID)
  • M — sort by memory usage instead of CPU
  • 1 — show individual CPU cores
  • q — quit

If top feels cramped, install htop — it’s the same idea with a friendlier, colorful interface and mouse support. Most beginners prefer it immediately.

Stopping Processes: kill and pkill

A frozen program? A runaway script eating your CPU? Kill it by its PID:

kill 1234

This sends SIGTERM — a polite “please shut down.” The process gets a chance to clean up. If it ignores you, escalate:

kill -9 1234

SIGKILL is the nuclear option: the process dies instantly with no cleanup. Use it when SIGTERM fails, not as your first move.

Don’t know the PID? Kill by name:

pkill firefox

And killall does the same with a slightly different matching rule. Just double-check the name before hitting enter — pkill python will end every Python script, including ones you wanted.

Signals Worth Knowing

  • SIGTERM (15) — polite shutdown request, the default
  • SIGKILL (9) — forced kill, no cleanup
  • SIGHUP (1) — often tells services to reload their config

Defense Angle

Processes are also where malware hides. If you see an unknown process burning CPU or a program you never installed listening on the network (ss -tulpn shows network listeners), investigate. Checking your processes is one of the simplest security habits you can build.

Learn this trio and your system stops being a black box. You’ll know what’s running, what’s misbehaving, and exactly how to stop it.

Comments

Popular Posts