System and processes

The jobs command

Lists the jobs of the current terminal: processes started in the background with & or stopped with Ctrl+Z. Each has a job number you can use with fg, bg and kill. It is how you control several processes from a single terminal.

Syntax

jobs [-lnprs] [%trabajo...]Try it in the terminal →

Most useful options

-lAdds the PID of each process to the list
-pShows only the PIDs, one per line. Useful in scripts
-rShows only the running jobs
-sShows only the stopped jobs

Copy-ready examples

$ sleep 100 & jobs -lstarts a process in the background and lists it with its PID. The PID differs on every machine.

Example output

[1]+   573 Running                 sleep 100 &
$ jobs -pjust the PID, to use with kill or in a script.

Example output

573
$ kill %1terminates job 1. %1 is the job number, not the PID.
$ fg %1brings job 1 to the foreground.

You can try them in the browser terminal: it does not touch your computer.

Common errors

MessageCauseFix
bash: jobs: %2: no such jobThere is no job numbered 2 in this terminal.List the jobs with jobs and no arguments, and use their number.
No error messagejobs only sees the jobs of this session. A process started from another terminal does not appear.Find the process with ps or pgrep.
No error messageA process removed with disown is no longer in the job table.Look for it with ps or pgrep by its name or PID.

Typical mistakes

  • Job numbers (%1) are not PIDs. If you confuse them, you will kill another process.
  • When the terminal closes, jobs receive SIGHUP and usually end, unless you use nohup or disown.
  • A stopped job does not advance until you resume it with bg or fg.
  • If you try to close the terminal with stopped jobs, the shell warns you before exiting.

Differences from similar commands

  • ps: lists the processes of the whole system, not only those of the terminal.
  • fg: brings a job to the foreground. jobs only lists and changes nothing.
  • kill: sends signals to a PID or a job (%1). jobs, on the other hand, does not terminate anything.

Related commands

FAQ

What is the difference between a job number and a PID?

The job number (%1) only works inside the current terminal. The PID is the process identifier across the whole system.

How do I pause a process?

Press Ctrl+Z. It stays stopped and appears in jobs with the Stopped state. Resume it with bg or fg.

Does a process started with & keep running when I close the terminal?

It depends. With nohup or disown it usually keeps running; without them the shell sends SIGHUP on exit and it usually ends.

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course