Job control is a basic feature of popular UNIX and Linux shells, such as “bash”.
It can be very useful, so I thought I’d make a little tutorial on it…
^C press Ctrl-C to interrupt a running job (you know this one!) ^\ press Ctrl-\ (backslash) to QUIT a running job (stronger) ^Z press Ctrl-Z to STOP a running job, it can be resumed later jobs type jobs for a list of stopped jobs (and background jobs) fg type fg to continue a job in the foreground bg type bg to continue a job in the background kill kill a job, e.g. kill %1, or kill -KILL %2 wait wait for all background jobs to finish
You can also use fg and bg with a job number, if you have several jobs in the list.
You can start a job in the background: put an &-symbol at the end of the command. This works well for jobs that write to a file, but not for interactive jobs. Things might get messy if you have a background job that writes to the terminal.
If you forget the % with kill, it will try to kill by process-id instead of job number. You don’t want to accidentally kill PID 1!
vi /etc/apache2/vhosts.d/ids.conf ^Z jobs find / >find.out & jobs fg 2 ^Z jobs bg 2 jobs kill %2 fg