Skip to Main Content
bash Pocket Reference
book

bash Pocket Reference

by Arnold Robbins
May 2010
Beginner to intermediate content levelBeginner to intermediate
130 pages
3h 20m
English
O'Reilly Media, Inc.
Content preview from bash Pocket Reference

Job Control

Job control lets you place foreground jobs in the background, bring background jobs to the foreground, or suspend running jobs. All modern Unix systems—including Mac OS X, GNU/Linux and BSD systems—support it, so the job control features are automatically enabled. Many job control commands take a jobID as an argument, which can be specified as follows:

%nJob number n
%sJob whose command line starts with string s
%?sJob whose command line contains string s
%%Current job
%+Current job (same as above)
%Current job (same as above)
%-Previous job

The shell provides the following job control commands. For more information on these commands, see the section Built-in Commands.

bg

Put the current job in the background.

fg

Put the current job in the foreground.

jobs

List active jobs.

kill

Terminate a job.

stty tostop

Stop background jobs if they try to send output to the terminal. (Note that stty is not a built-in command.)

suspend

Suspend a job-control shell (such as one created by su).

wait

Wait for background jobs to finish.

CTRL-Z

Suspend a foreground job. Then use bg or fg. (Your terminal may use something other than CTRL-Z as the suspend character, but this is unlikely.)

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Bash Pocket Reference, 2nd Edition

Bash Pocket Reference, 2nd Edition

Arnold Robbins
bash Quick Reference

bash Quick Reference

Arnold Robbins
Mastering Bash

Mastering Bash

Giorgio Zarrelli

Publisher Resources

ISBN: 9781449388669Errata Page