Background Jobs
Linux lets you run multiple tasks in one terminal.
Run in background
command & # Start in background
Output: [1] 12345 — job number and PID
Job control
jobs # List background jobs
bg %1 # Resume job 1 in background
fg %1 # Bring job 1 to foreground
fg # Bring most recent job to foreground
Suspend and resume
- Run a command in foreground
- Press
Ctrl+Zto pause it - Type
bgto resume it in background - Type
fgto bring it back
nohup — Run after logout
nohup command & # Run even after logout
nohup python3 server.py > server.log &
Output goes to nohup.out by default.
disown — Detach from shell
command &
disown %1 # Detach from shell
Practical example
# Start a long download in background
wget https://example.com/bigfile.zip &
# Check progress
jobs
# Bring to foreground to see output
fg %1