Korean

fg — Bring a background job to the foreground

Linux / Service and process management / fg.html

Service and process managementOriginalRegistered 2026-10-20T09:00:00+09:00

A shell builtin that moves a background or stopped job to the foreground for interaction.

Basic Information

Command Namefg
One-line IntroductionA shell builtin that moves a background or stopped job to the foreground for interaction.
Provided byBash and POSIX shell builtin
Official Documentationhttps://www.gnu.org/software/bash/manual/html_node/Job-Control-Builtins.html
Supported Operating SystemsLinux, macOS, BSD
Installation StatusInstalled by default (shell builtin)
CategoryLinux service and process management (tags: Process and resource management (tags: job control, foreground, shell))

What is this command?

fg brings a running background job or a stopped job back to the terminal foreground.

A foreground job receives keyboard input, and the prompt returns only when it finishes.

What problems does it solve?

  • Return to an editor you suspended.
  • Interact again with a program sent to the background.
  • Handle a job that needs a password prompt.
  • Watch progress directly on screen.

Key features

Foreground current

Run without a number to foreground the current job.

  • When to use: When recalling the job just backgrounded
  • What you get: Keyboard input available again
  • Limitations: The shell waits until the job ends

By job number

Specify a number from jobs to pick one job.

  • When to use: When choosing among jobs
  • What you get: Only that job comes forward
  • Limitations: A wrong number pulls a different job

Prompt return

The prompt returns when the foreground job exits.

  • When to use: After finishing an interactive job
  • What you get: Commands can be typed again
  • Limitations: Check exit status after abnormal ends

Installation and usage

Check whether it is installed

help fg

man bash # fg is a shell builtin

Real-world examples

Foreground current

Bring the background job forward.

# Bring the current background job to the foreground
fg

By number

Foreground job number 2.

# Foreground job 2
fg %2

Stop and return

Suspend with Ctrl+Z, then return with fg.

# Suspend with Ctrl+Z, then bring it back
fg