Quick take: Job control lets one shell manage several tasks. Press Ctrl+Z to suspend the running command, bg to resume it in the background, fg to bring it back to the foreground, and jobs to list them.
Introduction
Job control lets a single shell run and switch between multiple commands. You can suspend a running command, send it to the background, bring it back, and list everything in flight — all without opening another terminal. The trio jobs, bg, and fg, together with Ctrl+Z and &, make this possible.
Syntax
The basic syntax of the jobs, bg, and fg command is:
command & # start in background
Ctrl+Z # suspend foreground job
bg / fg [%N] # resume in background / foregroundCommon Options and Parameters
The most useful options and parameters for the jobs, bg, and fg command:
| Option | Description |
|---|---|
| Ctrl+Z | Suspend the current foreground job. |
| command & | Start a command in the background. |
| jobs | List the shell's jobs and their states. |
| jobs -l | List jobs with their PIDs. |
| bg %N | Resume job N in the background. |
| fg %N | Bring job N to the foreground. |
| kill %N | Terminate job N. |
Practical Examples
Real jobs, bg, and fg commands you can run today:
# Start a job in the background
./long-task.sh &
# Suspend a running command
(press Ctrl+Z)
# Resume it in the background
bg
# Bring it back to the foreground
fg
# List jobs with PIDs
jobs -l
# Bring a specific job forward
fg %2
# Kill a job
kill %1Tips and Best Practices
- Reference jobs with
%N(the job number fromjobs), e.g.fg %2orkill %1. Ctrl+Zthenbgrescues a long command you forgot to background — suspend it, then send it to the background.- Job control is per-shell; for tasks that must survive logout, use
nohup,disown, ortmuxinstead.
Final Thoughts
jobs, bg, and fg bring multitasking to a single shell — suspend with Ctrl+Z, background with bg or &, and resume with fg, all tracked by jobs. Reference them with %N. For work that must outlive the session, combine with nohup or a multiplexer like tmux.
FAQ: jobs, bg, and fg Command in Linux
How do I send a running command to the background?+
Press Ctrl+Z to suspend it, then type bg to resume it in the background. To start a command in the background from the outset, append & to it.
How do I bring a background job to the foreground?+
Use fg, or fg %N to choose a specific job by its number from the jobs list. The job then takes over the terminal again.
How do I list background jobs?+
Run jobs to see the shell's jobs and their states, or jobs -l to include their process IDs.
What does Ctrl+Z do?+
Ctrl+Z suspends the foreground job, pausing it and returning you to the prompt. You can then resume it with bg (background) or fg (foreground).
Do background jobs survive logout?+
No. Jobs started with & or bg are tied to the shell and end at logout. To keep a process running after you log out, use nohup, disown, or a terminal multiplexer like tmux.
Need help with Linux servers or infrastructure?
Work directly with Muhammad Irfan Aslam for Linux, Ubuntu, Docker, DevOps, cloud, CI/CD, or infrastructure support.
Hire Me for Support