The Linux Newbie Guide  ⇒    Fundamentals     Advanced     Supplement   Command Index   ENG⇒中
All rights reserved, please indicate the source when citing
  

bg Command: Moving Suspended Programs to the Background

bg Command for Moving Suspended Programs to the Background The bg (background) command allows you to move suspended programs to the background for execution. Its usage is bg %# (# represents the job number). You can omit the job number to refer to the last one.

Example:
$ seq 1 1000000 ← Outputs numbers 1 to 1000000
1
2
3 CTRL+Z ← Press <CTRL+Z> to suspend the current foreground program
[1]+ Stopped                seq 1 100000000 ← The current program is now suspended
$ seq 1 1000000 | tac ← Outputs numbers 1000000 to 1 (in reverse)
1000000
999999
999998
999997 CTRL+Z ← Press <CTRL+Z> to suspend the current program (in reverse)
[2]+ Stopped                seq 1 100000000 | tac ← The current program is now suspended (in reverse)
$ bg %1 ← Move the program with job number #1 to the background for execution
4
5
... (middle part omitted)
999999
1000000
$ bg ← Move the last suspended program to the background for execution
999996
999995
... (middle part omitted)
3
2
1


For more examples and explanations of operations, you can refer to the provided link.