LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

How do you run processes in the foreground and background?

Append & to start in the background; Ctrl+Z suspends a foreground job, then bg resumes it in the background and fg brings it back.

The shell's job control lets one terminal juggle several tasks. A foreground job owns the terminal (you can't type until it ends); a background job runs while the shell stays free for new commands. The key insight is that Ctrl+Z pauses rather than kills — it stops the job so you can decide what to do with it (bg, fg, or kill).

Action Command/Key
Run in foreground command
Run in background command &
Suspend the foreground job Ctrl+Z
Resume in background bg or bg %1
Bring to foreground fg or fg %1
List jobs jobs

%1 is a job number (from jobs), distinct from a PID — job control addresses jobs by these short numbers.

Example workflow:

$ sleep 1000        # Running in foreground
^Z                  # Press Ctrl+Z
[1]+ Stopped sleep 1000

$ bg                # Continue in background
[1]+ sleep 1000 &

$ jobs              # List background jobs
[1]+ Running sleep 1000 &

$ fg %1             # Bring back to foreground

Job status indicators:

  • + = Current job (default for fg/bg)
  • - = Previous job

Tip: Ctrl+Z doesn't kill - it pauses! Use bg to continue in background.

From Quiz: LIOS / Logs, Processes and Services | Updated: Jul 14, 2026