0Pricing
DevOps Bootcamp · Lesson

Job Control (bg, fg, jobs)

Master managing background and foreground processes, pausing, resuming, and listing jobs within your shell session.

Job Control (bg, fg, jobs) is a free DevOps Bootcamp lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

What is Job Control?

Welcome to Job Control! This powerful feature in your Linux shell lets you manage running programs without closing your terminal or opening new ones.

Think of it as multitasking for your command line. You can pause a task, move it to the background, or bring it back to the foreground.

Foreground vs. Background

When you run a command, it usually runs in the foreground. This means it takes control of your terminal, and you can't type new commands until it finishes.

A background process, however, runs independently. It frees up your terminal so you can continue working on other things while it executes.

Pausing a Process (Ctrl+Z)

To pause a currently running foreground process, use the keyboard shortcut Ctrl+Z. This sends a SIGTSTP signal, suspending the process.

The process doesn't terminate; it becomes a 'stopped' job, waiting for you to tell it what to do next.

Viewing Your Jobs (jobs)

Once you've paused a process (or sent one to the background), you can see a list of all active jobs in your current shell session using the jobs command.

Each job gets a unique job number (like [1], [2], etc.) and its status (e.g., Stopped, Running).

sleep 50 &
sleep 60 &
jobs

Bringing to Foreground (fg)

If you have a stopped or backgrounded job, you can bring it back to the foreground using the fg command, followed by its job number (e.g., %1).

This makes the job the active process in your terminal again.

sleep 100 &
jobs
# Now, let's bring it to foreground
fg %1

Sending to Background (bg)

To resume a stopped job and send it to the background, use the bg command with its job number.

The process will continue running without blocking your terminal, and you'll get your prompt back immediately.

sleep 200
# Press Ctrl+Z to stop it
# Then type:
bg %1
jobs

Running in Background ( & )

You don't always need to start a process in the foreground and then pause it. You can launch a command directly into the background by appending an ampersand (&) to the end of the command.

This is great for long-running tasks you don't need to interact with.

echo "Starting long task..." &
sleep 300 &
jobs

Job Numbers & PIDs

When you use jobs, you see job numbers like [1], [2]. These are specific to your shell session.

Every running process also has a unique Process ID (PID), which is a system-wide number. You can see PIDs with jobs -l or ps.

sleep 100 &
jobs -l

Stopping Jobs (kill)

To terminate a background or stopped job, you can use the kill command. You can specify the job number (e.g., kill %1) or its PID (e.g., kill 12345).

kill sends a signal to the process. By default, it's SIGTERM (graceful termination). For forceful termination, use kill -9 %job_number or kill -9 PID.

sleep 500 &
jobs
# Assuming sleep is job 1:
kill %1
jobs

Job Control Quiz

You've started a long-running command (e.g., find / -name *.txt), but now you need your terminal back to type a different command. What's the correct sequence to pause the find command, send it to the background so it continues running, and then confirm it's a background job?

Recap: Job Control

You've mastered job control!

  • Ctrl+Z pauses a foreground process.
  • jobs lists all active jobs.
  • fg %N brings a job N to the foreground.
  • bg %N sends a stopped job N to the background.
  • Appending & runs a command directly in the background.
  • kill %N or kill PID terminates a job.

This allows you to manage multiple tasks efficiently within a single terminal session!

Frequently asked questions

Is the “Job Control (bg, fg, jobs)” lesson free?

Yes — the full text of “Job Control (bg, fg, jobs)” is free to read here on the web, and the DevOps Bootcamp course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the DevOps Bootcamp course, upgrade to CoddyKit PRO.

What will I learn in “Job Control (bg, fg, jobs)”?

Master managing background and foreground processes, pausing, resuming, and listing jobs within your shell session. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start DevOps Bootcamp?

No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Job Control (bg, fg, jobs)” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this DevOps Bootcamp lesson?

Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Job Control (bg, fg, jobs)
  2. Shell Expansion & Globbing
  3. Aliases and Custom Prompts
  4. Shell Functions & Reusable Snippets
← Back to DevOps Bootcamp