
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!

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+Z
to stop the program - run
kill %1
to kill it (orkill -9 %1
if 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”
Saturday Morning Comics!
Want another comic like this in your email every Saturday? Sign up here!