bg — Resume a stopped job in the background
Linux / Service and process management / bg.html
A shell builtin that resumes a stopped job and keeps it running in the background.
Basic Information
| Command Name | bg |
|---|---|
| One-line Introduction | A shell builtin that resumes a stopped job and keeps it running in the background. |
| 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, background, shell)) |
What is this command?
bg resumes a job suspended with Ctrl+Z instead of killing it, continuing it in the background.
Without a job number it targets the current job, and it only works on shell-managed jobs.
What problems does it solve?
- Suspend an editor or build and continue it in the background.
- Regain the shell prompt while keeping a long job alive.
- Switch between several jobs.
- Clean up jobs left in the stopped state.
Key features
Resume the current job
Run without a number to resume the current job.
- When to use: When continuing the job just stopped
- What you get: Continues in the background
- Limitations: Output may interleave with the prompt
Resume by number
Specify a job number obtained from jobs.
- When to use: When resuming one of several jobs
- What you get: That job moves to the background
- Limitations: Jobs from other sessions cannot be targeted
Checking state
After resuming, use jobs to confirm it is running.
- When to use: When confirming the resume worked
- What you get: Shows the Running state
- Limitations: Completion still needs a separate check
Installation and usage
Check whether it is installed
help bg
man bash # bg is a shell builtin
Real-world examples
Resume current
Send the stopped job to the background.
# Resume the current stopped job in the background
bg
Resume by number
Resume job number 1.
# Resume job 1 in the background
bg %1
Verify
Check the job list afterwards.
# Confirm the job is running
jobs -l