fg command in Linux (original) (raw)

Last Updated : 2 May, 2026

The fg command in Linux is used to bring a background job to the foreground. It allows you to interact with the process directly through the terminal.

Example:

**Command:

sleep 60 &
fg %3

**Output:

fg

Output

Syntax

fg [job_spec]

The job_spec is a way to refer to the background jobs that are currently running or suspended.

Key Options for the fg command

1. fg [JOB_SPEC]:

This is the primary use of the fg command, bringing a specified job running in the background back to the foreground. For example, if you create a dummy job using sleep 500, you can bring it back to the foreground by referencing its job number:

**Command:

jobs
sleep 500

Press: Ctrl + Z

jobs
bg %1
jobs
fg %1

**Output:

 fg [JOB_SPEC]"sleep 500" is a command which is used to create a dummy job which runs for 500 seconds.

2. fg --help:

This option displays help information for the fg command, explaining usage and available options.

**Command:

fg --help

**Output:

fg --help