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

Bringing a Program to the Foreground



The fg command (short for foreground) is used to bring a paused or backgrounded program to the foreground for execution. Its usage is fg %# (where "#" represents the job number), and omitting the job number brings the last backgrounded job to the foreground.

Example:"
$ seq 1 200000000 > file & file & ←Generate a large file (~1.8GB) and run it in the background (this may take a while)
[1] 7687
$ fg ←Bring the background job to the foreground

In the above example, the seq command is running in the background. Therefore, you can't use <CTRL-Z> to pause or <CTRL-C> to terminate the program. However, using fg will bring the background process to the foreground, allowing you to interact with it.

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