backgrounding jobs

When you type a command on the Linux command-line, it runs in the foreground until it completes. That's fine for commands that run quickly, but if a job needs a lot of time to run, you probably want to type other things while it's running.

  • put an ampersand (&) at the end of the command line to run the job in the background, e.g.
    • cpu123% ./my-long-job &
    • now the prompt stays available to run more commands
  • see what jobs you have running in the background using the jobs command, e.g.
    • cpu123% jobs
      [1] + Running ./my-long-job
  • bring the first job from the background to the foreground in case you want to type at it:
    • cpu123% fg %1
  • put the first job in the background again:
    • cpu123% bg %1
  • terminate the first background job:
    • cpu123% kill %1