Forrest logo
back to the bg tool

bg:tldr:5523c

bg: Resume the most recently suspended job and run it in the background.
$ bg
try on your machine

The bg command is used in a Unix-based operating system to send a suspended or stopped job to the background, allowing it to continue running while the user can interact with the shell.

When a job is launched in the foreground, the shell waits for it to complete before accepting further commands. However, if a job is suspended or stopped using the ctrl-Z keyboard shortcut, it means it is paused and no longer running actively. In this state, the shell cannot accept any commands related to the job.

To allow the suspended or stopped job to continue running in the background, the bg command is used. By typing bg followed by the job ID (which can be obtained using the jobs command), the job is resumed in the background. This means the job will continue executing, but the user can still interact with the shell and issue other commands.

For example, let's say you have a long-running process (JOB1) that is currently suspended. Typing bg %1 (assuming JOB1 is the first job listed in the jobs command output) will resume the job in the background. Now JOB1 will continue executing, while the shell prompt becomes available to accept further commands.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the bg tool