Running Jobs in the Foreground with fg

Code Listing 9.8. Typing fg plus the job number brings that job into the foreground. When you bring suspended jobs into the foreground, you’ll sometimes see the job activities onscreen. At other times, you’ll see only a prompt and will need to summon help to see anything of the program.
[ejr@hobbes ejr]$ jobs
[1]+  Stopped   ftp ftp.cdrom.com
[ejr@hobbes ejr]$ fg %1
ftp ftp.cdrom.com

When you’re ready to resume a suspended or backgrounded job, you can do so using fg. Remember, when you suspend a job, what you’re doing is moving the job into limbo. fg just moves the job into the foreground again (Code Listing 9.8), so you can see, for example, what it’s doing or provide input.

To Run Jobs in the Foreground with fg:

1.
jobs

At the shell prompt, type jobs to list all stopped or running jobs. Note the job numbers at the left.

2.
fg %1

Enter fg followed by the number of the job that you want to bring back into the foreground (Code Listing 9.8).

Depending on the job you’re bringing back into the foreground, you may or may not get to see the job running onscreen. Sometimes you’ll be plunked back into the job and be able to enter information as prompted. Other times, you’ll just see the prompt for the program you returned to the foreground. If this is the case, try typing ? (for help), which often forces the program to display something onscreen and refresh the display.

✓ Tip

  • You can bring the last suspended job into the foreground by typing fg (with no job number) at the shell prompt.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.149.242