fg(1)
Bring a background job to the foreground.
Synopsis
fg [%jobspec]Description
The fg command moves a suspended or background job to the foreground, making it the active process that receives input from the terminal. If no job is specified, the most recently suspended job (or the current job) is brought to the foreground.
Jobs are identified by job number (e.g., %1, %2) or by command name prefix. This is a bash builtin command, not a standalone executable.
Common options
| Flag | What it does |
|---|---|
%jobspec | Bring the specified job to foreground; use %1 for first job, %2 for second, etc. |
%command | Bring the job whose name begins with 'command' to foreground |
%% | Refer to the current job (same as %+) |
%+ | Refer to the current job |
%- | Refer to the previous job |
Examples
Bring job number 1 to the foreground
fg %1Bring the wget job to the foreground (job name must start with 'wget')
fg %wgetBring the current job (most recently suspended) to the foreground
fgBring the previous job to the foreground
fg %-List all jobs, then bring job 2 to the foreground
jobs; fg %2Start a background job, then bring it to the foreground with a single command
sleep 1000 &
fg