How to Use the jobs Command to Manage Background Processes in Linux

The Problem with Terminal Execution

In a standard graphical operating system like Windows or macOS, you can easily open Firefox, minimize it, open Microsoft Word, minimize it, and then open a calculator. All three applications run simultaneously in the background.

However, the Linux terminal is, by default, a single-threaded environment. If you run a command that takes 30 minutes to complete (such as downloading a massive 50GB file using wget, or compiling a massive software package using make), that process entirely consumes your terminal session. You cannot type any other commands until that specific job finishes. If you attempt to press Ctrl+C, you will instantly kill the process, destroying your progress.

To solve this, Linux allows you to push processes into the “background” of the terminal, freeing up your command prompt while the process continues to run silently. The jobs command is the essential tool for tracking and managing these hidden background tasks.

Step 1: Pushing a Command to the Background

If you know a command is going to take a long time, you can instruct Linux to launch it straight into the background by appending an ampersand (&) to the very end of the command.

wget https://example.com/massive_file.iso &

The terminal will instantly reply with something that looks like this: [1] 49832, and immediately give you your command prompt back.

Alternatively, if you already started a command normally and it is currently freezing your terminal, press Ctrl+Z. This suspends (pauses) the process. You can then type the bg (background) command to un-pause it and force it into the background.

Step 2: Viewing Your Background Jobs

Once you have pushed two or three massive tasks into the background, it is easy to forget what is actually running. To view a complete list of every background task attached to your current terminal session, simply run:

jobs

The output will look like this:

[1]-  Running                 wget https://example.com/massive_file.iso &
[2]+  Stopped                 nano /etc/config.txt
[3]   Running                 tar -czvf backup.tar.gz /home/user/ &

Step 3: Understanding the Output

The output of the jobs command is highly specific:

  • Job Number (e.g., [1]): This is the internal ID assigned to the job by your shell. It is not the system-wide Process ID (PID).
  • Plus and Minus (+/-): The + indicates the “current” job (the last one you interacted with). The - indicates the “previous” job.
  • Status (Running / Stopped): A “Running” job is actively executing code in the background. A “Stopped” job is completely frozen in time (usually because you pressed Ctrl+Z) and is doing absolutely nothing until you manually unfreeze it.
  • Command: The actual text string of the command you executed.

Step 4: Pulling a Job Back to the Foreground

If you pushed a massive wget download into the background, but you now want to watch the visual progress bar to see when it finishes, you must pull it back into the foreground (thereby freezing your terminal again).

You use the fg (foreground) command, followed by a percent sign (%) and the Job Number.

To bring the wget download (Job 1) back to your screen, run:

fg %1

Step 5: Killing a Background Job

If you realize that your background tar backup command (Job 3) is compressing the wrong directory, you do not need to pull it into the foreground just to kill it. You can instantly terminate it while it is still hidden by using the kill command combined with the Job Number syntax.

kill %3

The next time you type jobs, you will see a message confirming that Job 3 has been Terminated, keeping your terminal environment clean and efficient.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.