/ factorpad.com / tech / linux-essentials / jobs-command.html
An ad-free and cookie-free website.
Intermediate
Learn to show jobs at the Linux command line.
Videos can also be accessed from the Linux Essentials Playlist on YouTube.
Linux jobs Command Summary with Examples (3:39)
Our sixty-third word, or command to memorize is
jobs
from our category
System.
jobs
allows you to show jobs in the
terminal.
-options | description |
---|---|
-l |
Include process IDs |
-r |
List only running jobs |
-s |
List only stopped jobs |
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.
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.
Nothing. Wondering if it's your system, you try
whatis
and get this.
Don't despair, it's there, and
type
says that it's 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.
And then now, jobs
shows the job.
We can add the Process ID (PID) number with
-l
.
Or -r
for running.
But a -s
only show stopped jobs.
And last, let's bring the job to the foreground with
fg %1
.
Then stop it with Ctrl-z
.
And then run a jobs -s
.
And there it is, stopped. Very good.
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.
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
Our YouTube Channel is about learning faster, subscribe there and @factorpad on Twitter for reminders of new content.
uname
command,
hit Back.dpkg
command, click Next./ factorpad.com / tech / linux-essentials / jobs-command.html
A newly-updated free resource. Connect and refer a friend today.