Skip to content

What’s running? ps and kill

IntermediateLesson 26 of 666 min

List every running program with ps aux, read its PID and CPU columns, and stop a runaway process with kill. Practise on a pretend busy laptop in your browser.

Every program that's running is a process, and each one has a number, its PID (process ID). The system knows them by these numbers, and so will you.

ps: what's running

ps on its own lists the processes started from this terminal. ps aux lists every process on the machine:

ps aux

The columns you'll read most:

ColumnMeans
USERwho runs it
PIDits process ID
%CPUhow much of a processor it uses
%MEMhow much memory it uses
COMMANDthe program and what it was started with

To find one program, filter the list (grep shows up in it too, since it is running at that moment), or ask pgrep for the PID:

ps aux | grep cron
pgrep cron

kill: stop it

kill PID asks a process to stop. Well-behaved programs tidy up and exit:

kill 12345

If one ignores that, kill -9 PID ends it at once, with no chance to save anything, so keep it for last. You can only stop your own processes; other users' need sudo. pkill NAME and killall NAME stop processes by name.

Your turn

The laptop’s fan is roaring. List every process, find the one that is using almost all of the CPU, and stop it with kill. Then check that it has gone.

Next