Linux bg Command: Resume a Shell Job in the Background

bg resumes a stopped job in the background in Bash. It is used when you want to stop a running command with Ctrl+Z and continue using the terminal.

What is the bg command?

bg sends a continue signal to a stopped job but does not give front control of the terminal. You can check the job number with jobs and specify it like %1. Interactive programs waiting for input may stop again in the background.

Basic syntax

bg [%job number]

The installed implementation and options may vary depending on the distribution. Check the description for your system with help bg.

Examples

Checking stopped jobs

After pressing Ctrl+Z during a foreground command execution, check the status.

jobs -s

Resuming a specific job in the background

In the example, replace %1 with the actual number from the jobs output.

bg %1

Check resume result

Check if it is in the Running state.

jobs -l

Running a Paused Job in the Background

bg continues a job that is currently paused in the background of the current shell. For example, after running sleep 60 and stopping it with Ctrl+Z, check the job number.

jobs
bg %1
jobs

Example of state changes:

[1]+  Stopped  sleep 60
[1]+  Running  sleep 60 &

%1 refers to job number 1 in the current shell, not the PID. If the shell does not support job control or there are no paused jobs, bg will fail. When a job finishes, it may disappear from jobs, so check the status again.

Main Options and Format

Options/Format Description
%N Specify job number N of the current shell.
%+ Specify the current job.
%- Specify the previous job.
Omit argument Use the job that Bash considers the current job.

Precautions when using

A job stopped with Ctrl+Z is not yet running. A job that tries to read from standard input may be stopped again even if resumed with bg. bg is a shell job control feature and cannot be applied to processes started in another terminal.

Frequently Asked Questions

Are appending & at the end of a command and using bg the same?

& starts the command in the background from the beginning, while bg resumes a currently stopped job in the shell in the background.

Official Documentation

The exact behavior of these options and implementation differences can be found in the official bg documentation.

More in This Category
Linux last Command: Review Login and Reboot History

Linux last Command: Review Login and Reboot History

Learn how to use the Linux last command to review user login sessions, system reboots, and shutdown history, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux Tutorial / File Types and Metadata: ls, file, stat, and readlink

Linux Tutorial / File Types and Metadata: ls, file, stat, and readlink

Learn what ls, file, stat, and readlink each reveal about a Linux file, including type, size, timestamps, and symbolic-link targets.

Linux Tutorial / Choosing a Linux Distribution

Linux Tutorial / Choosing a Linux Distribution

Explore major Linux distributions and learn when to choose Ubuntu LTS or Rocky Linux for study and server practice. Compare package management, release policies, and practical selection criteria.

Linux lscpu Command: Inspect CPU Architecture and Cores

Linux lscpu Command: Inspect CPU Architecture and Cores

Learn how to inspect CPU Architecture and Cores with the Linux lscpu command, including practical examples, key options, and important precautions.

Linux Tutorial / File Permissions and Safe sudo Use

Linux Tutorial / File Permissions and Safe sudo Use

Learn to read file and directory permissions, practice chmod safely, and understand when to use sudo and how to diagnose access errors.

A History of Linux: From a 1991 Hobby Project to Global Infrastructure

A History of Linux: From a 1991 Hobby Project to Global Infrastructure

Trace the history of Linux from Unix and the GNU Project through the first Linux kernel, distributions, enterprise adoption, cloud computing, containers, and modern infrastructure.

Linux stat Command: Display Detailed File Metadata

Linux stat Command: Display Detailed File Metadata

Learn how to use the Linux stat command to inspect file size, permissions, ownership, timestamps, inode, and filesystem metadata, with essential options, practical examples, output interpretation, and common troubleshooting tips.

Linux uniq Command: Remove or Count Adjacent Duplicate Lines

Linux uniq Command: Remove or Count Adjacent Duplicate Lines

Learn how to remove or count adjacent duplicate lines with the Linux uniq command, including practical examples, key options, and important precautions.

Linux nmap Command: Scan Authorized Hosts and Ports

Linux nmap Command: Scan Authorized Hosts and Ports

Learn how to scan Authorized Hosts and Ports with the Linux nmap command, including practical examples, key options, and important precautions.

Linux top Command: Monitor Processes in Real Time

Linux top Command: Monitor Processes in Real Time

Learn how to monitor Processes in Real Time with the Linux top command, including practical examples, key options, and important precautions.