What’s running? ps and kill
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 auxThe columns you'll read most:
| Column | Means |
|---|---|
| USER | who runs it |
| PID | its process ID |
| %CPU | how much of a processor it uses |
| %MEM | how much memory it uses |
| COMMAND | the 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 cronpgrep cronkill: 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.
Your task
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.
- List every process (ps aux) (not done yet)
- Stop the runaway process (not done yet)
- Check that it has gone (not done yet)
The checklist ticks itself off as you work in the terminal: any way that gets the result counts.
Hints come one at a time, then one way to do it. Try each before the next.
What this lesson uses, in one place.
ps- List running processes More on ps
ps aux- Every process, with user, %CPU, %MEM, start time and command More on ps
kill- Send a signal to a process (usually: stop it) More on kill
kill -9- End it now More on kill
pgrep- Find processes by name
Every everyday command on one page: the Linux commands cheat sheet.