Vol. I · No. 46The command line sectionSat, 10 Oct 2026
Linux · process & service management

jobs

background and foreground

jobs shows what the current shell is running besides the command in front of you. Ctrl+Z pauses a running command; bg lets it continue in the background; fg brings it back — a way to do two things in one terminal.

Ctrl+Z, then bg moves a command you forgot to start in the background out of the way.

Start in background
command &
the prompt returns at once
Pause
Ctrl+Z
the job is stopped, not ended
Resume
bg or fg
background or foreground
Refer to one
%1, %2
the job number

At the terminal

Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.

user@netflow — bashbash
$ sleep 300 &
1[1] 4410
$ ping 192.0.2.1 > ping.log
2^Z
[2]+ Stopped ping 192.0.2.1 > ping.log
3$ bg %2
[2]+ ping 192.0.2.1 > ping.log &
4$ jobs
[1]- Running sleep 300 &
[2]+ Running ping 192.0.2.1 > ping.log &
Illustrative session · names, sizes and dates are examples, and every address is from a documentation or private range
Reading the output

What the numbered lines are telling you

1
& starts a job in the background

[1] is the job number in this shell and 4410 is the process id. The prompt comes straight back.

2
Ctrl+Z stops the foreground command

ping is paused, not ended. It is not running at all until it is resumed.

3
bg resumes it in the background

Job 2 continues, and the terminal is free for other commands.

4
Both running

The + marks the job that fg or bg acts on by default. "fg %1" would bring the sleep to the foreground.

Switches

A switch changes how the command behaves. These are the ones used day to day; man jobs lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.

-l
Also list each job’s process id.
-p
List only the process ids.
-r
Show running jobs only.
-s
Show stopped jobs only.

Variations worth knowing

The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.

fg

Brings the most recent job back to the foreground.

kill %1

Ends job number 1.

jobs -l

Lists jobs with their process ids.

disown %1

Detaches a job from the shell, so closing the terminal does not end it.

In cybersecurity

A background job belongs to the terminal that started it.

Jobs die with the session

Closing the terminal or losing the SSH connection ends its jobs. For work that must survive, use nohup, tmux or a systemd service.

Forgotten background processes

A test server left running with & keeps listening after you have moved on. Check jobs and "ss -tlnp" before leaving a machine.

Stopped is not finished

A job paused with Ctrl+Z still holds its files and its port. The shell warns "There are stopped jobs" when you try to exit.

Filed under

Process & service management

Read alongside