How to move jobs to the background in the Linux system?

To move foreground jobs to the background in a Linux system, we use the bg command. This is particularly useful when you have a running process that you want to continue executing without blocking your terminal.

bg (background) − The bg command resumes execution of a suspended process in the background. When a job is moved to the background, it continues running but no longer occupies the foreground of your terminal session. If no job is specified, the bg command works on the most recently suspended job.

Syntax

The general syntax of the bg command is as follows −

bg [job_spec ...]

Job Control Process

Before using bg, you typically need to suspend a running process using Ctrl+Z. This stops the process and gives you back control of the terminal. You can then use bg to resume it in the background.

Job Control Process Flow Start Process Running in Foreground Ctrl+Z (Suspend) bg command (Resume) Running in Background

Job Identifiers

Notation Meaning
%n Job number (where n is the job ID)
%string Refer to a job which was started by a command beginning with string
%?string Refer to a job which was started by a command containing string
%% or %+ Current job (most recently suspended)
%- Previous job (second most recently suspended)

Examples

Basic Usage

Start a long-running process, suspend it, then move to background −

$ sleep 200
^Z
[1]+  Stopped                 sleep 200
$ bg
[1]+ sleep 200 &

Working with Specific Jobs

Move the most recent job to background −

$ bg %%

Move a specific job by ID to background −

$ bg %2

Move job by command name to background −

$ bg %sleep

Checking Job Status

Use the jobs command to list all jobs and their status −

$ jobs
[1]-  Running                 sleep 300 &
[2]+  Running                 ping google.com &

Exit Status

The bg command returns success (exit status 0) unless job control is not enabled or an error occurs. Common error conditions include specifying a non-existent job or attempting to background a job that cannot be backgrounded.

Related Commands

  • fg − Brings background jobs to the foreground

  • jobs − Lists all active jobs

  • nohup − Runs commands immune to hangups

  • & − Starts a command directly in the background

Conclusion

The bg command is essential for job control in Linux, allowing you to move suspended processes to the background where they continue running. This enables efficient multitasking by freeing up your terminal while keeping processes active. Use it in combination with Ctrl+Z and the jobs command for effective process management.

Updated on: 2026-03-17T09:01:38+05:30

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements