FactorPad
Faster Learning Tutorials

Linux jobs command summary with examples

jobs allows you to show jobs in the terminal.
  1. Purpose - Learn what jobs is for and how to find help.
  2. Options - Review a few common options and arguments.
  3. Examples - Walk through code examples with jobs.
  4. A tip - Finish off with one more insight.
Paul Alan Davis, CFA, November 2, 2016
Updated: August 4, 2018
In this tutorial, 63 of 100, below find a 3-4 minute introductory video, a text-based tutorial and all of the code examples from the video.

Outline Back Next

~/ home  / tech  / linux essentials  / jobs command


The Linux jobs command

Intermediate

Learn to show jobs at the Linux command line.

Video Tutorial

Linux jobs command summary with examples (3:39)

Videos can also be accessed from the YouTube Playlist.

Video Script

The Command and Why You Need It

Our sixty-third word, or command to memorize is jobs from our category System.

jobs allows you to show jobs in the terminal.

Recall from videos 45, 59 and 60 on ps, kill and bg, we saw jobs on the system, and here we'll see jobs local to this terminal session.

Before we start, it helps to think of commands as mini programs and most follow this structure: command -option(s) argument(s).

The jobs command has 5 options and the argument is the job.

Unlike most commands, help is not available with double-dash --help as jobs is a shell built-in (builtin) on most Linux distributions. Again, you can find details on job control in the exhaustive man page on bash.

The -l option includes process IDs, just as with the ps command. Use -r for running jobs and -s for stopped jobs only.

So why is jobs an important command? Well, you might be only concerned with finding what you're doing in your terminal session and not the whole system. And now you know how to do that.

Demonstration

Okay, the best way to embed this in your memory is by typing in your own terminal window.

Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.

Here we go. So maybe on your end the jobs command looks like this.

$ jobs $ _

Nothing. Wondering if it's your system, you try whatis and get this.

$ whatis jobs jobs: nothing apropriate

Don't despair, it's there, and type says that it's a shell builtin.

$ type jobs jobs is a shell builtin

So it works, but no local terminal jobs are present, so we'll create a sleep job for 5 minutes, like this.

$ sleep 5m & [1] 303

And then now, jobs shows the job.

$ jobs [1]+ Running sleep 5m &

We can add the Process ID (PID) number with -l.

$ jobs -l [1]+ 303 Running sleep 5m &

Or -r for running.

$ jobs -r [1]+ Running sleep 5m &

But a -s only show stopped jobs.

$ jobs -s $ _

And last, let's bring the job to the foreground with fg %1.

$ fg %1 sleep 5m _

Then stop it with Ctrl-z.

$ fg %1 sleep 5m ^Z [1]+ Stopped sleep 5m

And then run a jobs -s.

$ fg %1 sleep 5m ^Z [1]+ Stopped sleep 5m

And there it is, stopped. Very good.

A Final Tip

Okay now you know how to use jobs. And you know the syntax for commands, options and arguments.

One last tip about the jobs command. So if that fg command is new to you, we didn't have a separate video (tutorial) on it, but did mention it in video 60. If you want to check that out.

Okay, thanks for visiting today. I hope this was a helpful introduction to the jobs command.


Learn More About The Series

For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:


What's Next?

Our YouTube Channel is about learning faster, subscribe here and check it out.

  • For the Outline to all 100 tutorials, click Outline.
  • To go back to the uname command, hit Back.
  • To keep learning about the system and switch to how software packages work with the dpkg command, click Next.

Outline Back Next

~/ home  / tech  / linux essentials  / jobs command



 
 
Keywords:
linux jobs command
linux job control
show jobs linux
display jobs in linux
running jobs in linux
stopped jobs in linux
fg jobs linux
bg jobs linux
shell jobs
ctrl z linux
PID linux
Process ID
terminal jobs
linux jobs examples
man jobs