Skip to content
shellmap

bgResume a stopped (Ctrl+Z’d) job and run it in the background across all 5 shells

Equivalents in every shell

Bashunix
bg %1
Zshunix
bg %1
Fishunix
bg 1

fish accepts a bare integer ID — no leading `%`.

PowerShellwindows
Start-Job { command }

PowerShell has no "stopped" job state — you cannot suspend a foreground command with Ctrl+Z and resume it. Background a command from the start with `Start-Job`, `Start-ThreadJob`, or the `&` background operator (PS 6+: `command &`).

cmd.exewindows
start /b command

cmd has no Unix-style job control. Launch a command detached with `start /b` from the get-go; you cannot suspend a running cmd command and push it to the background afterwards.

Worked examples

Suspend the current foreground command then put it in the background

Bash
# press Ctrl+Z, then:
bg
Fish
# press Ctrl+Z, then:
bg

Resume a specific stopped job in the background

Bash
bg %2
Fish
bg 2

Start a long-running command in the background from the start

Bash
long-task &
Fish
long-task &
PowerShell
Start-Job { long-task }
cmd.exe
start /b long-task

Gotchas

  • You must suspend with `Ctrl+Z` (which sends `SIGTSTP`) first — `bg` only works on jobs already in the "Stopped" state.
  • A backgrounded job still writes to your terminal unless redirected. Start cleanly with `command > out.log 2>&1 &` to avoid output bleeding into your prompt.
  • Closing the terminal sends `SIGHUP` to backgrounded jobs and they die. Use `disown %1` (bash / zsh) or `nohup` to detach permanently.
  • PowerShell and cmd lack `SIGTSTP` semantics — there is no way to pause an already-running command and resume it later. Plan ahead and start it as a job.

WSL & PowerShell Core notes

pwshpwsh has no SIGTSTP / `bg` semantics on any platform — you cannot Ctrl+Z a running interactive command and push it to the background. The pwsh 6+ `command &` background operator is closer to bash's start-as-background `command &` than to the resume-from-suspended `bg`. On Linux/macOS pwsh hosts, native Unix job control is unavailable inside pwsh itself; drop to bash via `bash -c 'long-task &'` if you specifically need the SIGTSTP/SIGCONT lifecycle.
WSLWSL bash `bg` works identically to native Linux — Ctrl+Z suspends (SIGTSTP), `bg` resumes in background (SIGCONT). Jobs backgrounded inside WSL do NOT survive a `wsl --shutdown` (which terminates the entire lightweight VM, not just the shell), so `nohup` alone does not save them across that. For tasks that must outlive the WSL session, use Windows-side Task Scheduler or a Linux `systemd --user` unit (WSL2 supports systemd since Windows 11 22H2 with `[boot] systemd=true` in `/etc/wsl.conf`).

Common tasks using bg

Related commands