Processes, Jobs, and Stopping Things

What this is. Every running program is a process with a numeric id. When something is stuck, consuming your machine, or holding a port you need, these are the commands that deal with it.

ps aux lists every process.

ps aux | grep node finds the ones you care about.

kill 1234 asks a process to stop.

kill -9 1234 forces it, and should be a last resort.

✦ Ask before you force

Plain kill sends a polite request, and a well written program uses it to finish writing files and close connections before exiting. kill -9 cannot be caught or refused, so the process stops immediately with no chance to clean up, which can leave half written files behind. Try kill first every time, and reserve -9 for something that genuinely will not respond.

Foreground, background, and getting your prompt back.

A command with & after it runs in the background, handing your prompt straight back.

jobs lists what you have backgrounded in this shell.

Control and C interrupts whatever is running in the foreground.

Control and Z suspends it, and fg resumes it in the foreground.

The shortcuts that make the terminal comfortable. These are worth practicing deliberately, because they are the difference between fighting the line and editing it.

Control and C stop. Control and L clear the screen. Control and R search your history. Control and A jump to the start of the line, Control and E to the end. Control and U delete backwards to the start, Control and K forwards to the end. And the up arrow walks back through previous commands.

SANKOFA SANDBOX
learner:~$

The process table here is fixed but real enough to practice on. Try backgrounding something with a trailing ampersand.

Try it → Run `ps aux`, then `ps aux | grep node` to filter it. Then `kill 907` and run `ps` again to confirm it is gone. Try `kill 1` and read why it refuses.

◈ Graded Task

Take control of the environment. Set a variable called PROJECT to the value archive, and write the value of your PATH into path.txt in your home directory. Then find the process running node and stop it.

Checked against the filesystem you leave behind, not the commands you type, so any route that gets the job done counts. 4 visible and 2 hidden checks.

SANKOFA SANDBOX
learner:~$

Mark this lesson complete

Signed in, your progress follows you to every device.

Next: Practice Test →
← Back