Frequently Asked Question

How do I manage background jobs with Ctrl+Z, bg, fg, and jobs?

Job control lets one terminal manage several long-running commands. Press Ctrl+Z and the foreground process is paused, the terminal sends it SIGTSTP, the kernel stops it, and you get your prompt back. Type jobs and you'll see the suspended command listed with a number in square brackets. fg %1 resumes it in the foreground; bg %1 resumes it in the background so it keeps running while you use the shell for something else.

You can also start a command in the background straight away by appending &: make -j8 & runs make while leaving you free to do other things. When a background job finishes, bash prints a one-line notice before the next prompt. disown removes a job from the shell's table so it won't be killed when the shell exits; nohup cmd & does roughly the same thing but also redirects output and ignores SIGHUP. For anything that should outlive a session entirely, use tmux or screen instead.

Video

Further reading and video