Linux bg command

Updated: 12/29/2017 by Computer Hope

About bg

bg is a job control command that resumes suspended jobs while keeping them running in the background.

The presence of bg in an Operating System is required for it to be POSIX-compliant.

bg syntax

bg [job]



Specifies the job that you want to run in the background.

Job number 1 is referred to as %1, job number 2 is referred to as %2, etc.;

%, %+, or %% refers to the current job;

%- or - refers to the previous job.

bg examples

In this example, let's assume we are in the bash shell.

If you initiate a process at the command line, and you want to return to the command line prompt before the program is finished executing to do something else (e.g., check your mail, edit a text file, whatever) you can press Control-Z and the job will stop.

If you then run the command:

bg %1

The stopped job will resume operation, but remain in the background. It will not receive any input from the terminal while it's in the background, but it will keep running, and you can continue to use the shell from the command line.

cancel — Cancels a print job under the System V operating system.
fg — Resumes a suspended job and brings it to the foreground.
jobs — List the status of all running jobs.
kill — Send a signal to a process, affecting its behavior or killing it.
lpstat — List the status of the LP print services.
ps — Report the status of a process or processes.
stop — Stop a running job.