$linuxjunkies
>

fg(1)

Bring a background job to the foreground.

UbuntuDebianFedoraArch

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

FlagWhat it does
%jobspecBring the specified job to foreground; use %1 for first job, %2 for second, etc.
%commandBring 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 %1

Bring the wget job to the foreground (job name must start with 'wget')

fg %wget

Bring the current job (most recently suspended) to the foreground

fg

Bring the previous job to the foreground

fg %-

List all jobs, then bring job 2 to the foreground

jobs; fg %2

Start a background job, then bring it to the foreground with a single command

sleep 1000 &
fg

Related commands