Jobs run in the foreground unless otherwise specified. To launch a job in the background end the command line with an ampersand (&).
Example…
Run apropos shell > shell-commands in the background…
af@gaga:~$ apropos shell > shell-commands & <Enter>
[1] 18721
af@gaga:~$
The shell outputs the job number (here it is 1) and process ID (here it is 18721) and then returns the shell prompt. When the background job finishes it will return the job number, the command and the text “Done” indicating that the job has finished.
[1]+ Done apropos shell > shell-commands
To move a foreground job into the background one must suspend it (<Ctrl>-<Z>) and then type bg.
Example…
Start the text editor vi in the foreground, suspend it and then move it into the background…
af@gaga:~$ vi <Enter> <Ctrl>-<Z>
[1]+ Stopped vi
af@gaga:~$ bg <Enter>
[1]+ vi &
[1]+ Stopped vi
af@gaga:~$ <do something>
af@gaga:~$ fg <Enter>
This could be useful while editing a file using vi.
If one has many jobs suspended then specify the job to be put in in the background by giving its job number as an argument to bg…
Example…
To run job 5 in the background type…
$ bg %5 <Enter>