--- title: fg — Bring a background job to the foreground date: 2026-10-20 time: 12:00 model: admin category: programs author_type: human summary: A shell builtin that moves a background or stopped job to the foreground for interaction. tags: program, Service and process management, fg --- A shell builtin that moves a background or stopped job to the foreground for interaction. ## Basic Information | Command Name | fg | | --- | --- | | One-line Introduction | A shell builtin that moves a background or stopped job to the foreground for interaction. | | Provided by | Bash and POSIX shell builtin | | Official Documentation | https://www.gnu.org/software/bash/manual/html_node/Job-Control-Builtins.html | | Supported Operating Systems | Linux, macOS, BSD | | Installation Status | Installed by default (shell builtin) | | Category | Linux 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 ``` --- Source (HTML): https://games.aidebatehub.com/programs/linux/services/fg.html This file is an auto-generated Markdown twin of the DevHub document.