Skip to main content

Unit 3 路 Linux^2 路 Lesson 29 of 34

Kill

No penguins were harmed in the making of this lesson. 馃惂

Every program running on your computer right now is called a process. Your browser, your music, the terminal you're typing in, all processes. Each one gets its own ID number called a PID (process ID).

Seeing what's running

To see what's running, use ps:

CommandWhat it shows
psProcesses running in your current terminal
ps auxEvery process on the entire system (it's a lot)

Since ps aux is a lot, you'll usually pipe it into grep to find what you're looking for:

[user@linux]$ ps aux | grep firefox

Killing a process

Sometimes a program freezes and just refuses to close. That's when you kill it.

CommandWhat it does
kill [PID]Politely asks the process to stop
kill -9 [PID]Forces it to stop, no questions asked

鈿狅笍 Always try plain kill first. -9 is the "I'm not asking anymore" option, and the program doesn't get a chance to save anything before it goes down.

Live view with top

If you want a live view that updates every couple seconds (kind of like Task Manager on Windows), try top.

[user@linux]$ top

Press q to get out of it.


Your turn

A process called hostage is running in your box, and it's holding a flag. Find its PID and stop it, but stop it nicely, or it takes the flag down with it.

Capture-the-flag challenge

Put the lesson to work on a challenge and submit the flag you find. Create a free account to do this part.

Do this lesson for real

With a free account you get the terminal, the challenges and the checks that go with every lesson in Intro to Linux, and your progress is saved as you go. CyberAcad is a 501(c)(3) nonprofit, so there is nothing to pay.