Here's a preview from my zine, The Secret Rules of the Terminal! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!
get the zine!
read the transcript!
your shell lets you run many programs (“jobs”) in the same terminal tab
programs can either be:
- foreground
- background
- stopped (which is more like “paused”)
& runs a program in the background
for example I like to convert 100 files in parallel like this:
for i in `seq 1 100`
do
convert $i.png $i.jpg &
done
jobs lists backgrounded & stopped jobs
$ jobs
[1] Running python blah.py &
[2] Stopped vim
use the numbers to bring them to the foreground or background (like fg %2), kill them (kill %2), or disown them
when you close a terminal tab all jobs are killed with a SIGHUP signal
you can stop this with disown or by starting the program with nohup:
disown %1 (job number goes here)
nohup my_program &
a trick to kill programs if Ctrl+C doesn’t work
- press
Ctrl+Zto stop the program - run
kill %1to kill it (orkill -9 %1if you’re feeling extra murderous)
a little flowchart
Three boxes, labelled “running in foreground”, “stopped”, and “running in background”
Ctrl+Z goes from “running in foreground” to “stopped”
fg goes from “stopped” to “running in foreground”
fg goes from “running in background” to “running in foreground”
bg goes from “stopped” to “running in background”