Job 2 shows the find command I just ran. Jobs 3 and 4 show
nroff commands currently running in the background. Job 5 had been running in the shell (foreground)
until I decided too many processes were running and pressed Ctrl+Z to stop job 5 until a
few processes had completed.
The plus sign (+) next to number 5 shows that it was most recently placed in the background. The
minus sign (-) next to number 4 shows that it was placed in the background just before the most
recent background job. Because job 1 requires terminal input, it cannot run in the background. As
a result, it is Stopped until it is brought to the foreground again.
To see the process ID for the background job, add a -l (the lowercase letter L) option
to the jobs command. If you type ps, you can use the process ID to figure out which
command is for a particular background job.
Using Foreground and Background Commands
Continuing with the example, you can bring any of the commands on the jobs list to the foreground.
For example, to edit myfile again, type:
$ fg %1
As a result, the vi command opens again, with all text as it was when you stopped the vi job.
TIP
TIP
64
Linux First Steps Part I
Before you put a text processor, word processor, or similar program in the background,
make sure you save your file.
Pages:
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218