Entering a command line will start a job. Try typing man cp, and the cp manual page will appear on the screen. The shell will go into the background and return when you finish reading the manual page (or you can press q to quit rather than scrolling through the whole thing).

But say you’re reading the manual page, and you want to do something else for a minute. No problem. Press Ctrl-z while you’re reading to _suspend_ the current foreground job and put the shell in the foreground. When you suspend a job, bash will first give you some information on it, followed by a shell prompt. You will see something like this on the screen:

Debian GNU/Linux : Guide to Installation and Usage — Part 48

NAME cp - copy files SYNOPSIS cp [options] source --More-- [1]+ Stopped man cp $

Debian GNU/Linux : Guide to Installation and Usage — Part 48

Note the last two lines. The next to last is the job information, and then you have a shell prompt.

Debian GNU/Linux : Guide to Installation and Usage — Part 48

bash assigns a _job number_ to each command line you run from the shell. This allows you to refer to the process easily. In this case, man cp is job number 1, displayed as [1]. The + means that this is the last job you had in the foreground. bash also tells you the current state of the job—Stopped—and the job’s command line.

There are many things you can do with jobs. With man cp still suspended, try the following commands:

Suspends the man ls job; you should see its job information.

Asks bash for a display of current jobs. The result looks like this:

{ $} jobs [1] Stopped man cp [2]- Stopped man ls [3]+ Stopped man mv { $}

Notice the - and +, denoting respectively the next to last and last foreground jobs.

Places the last foreground job (man mv, the one with the +) in the foreground again. If you press the space bar, the man page will continue scrolling.

You can refer to any job by placing a % in front of its number. If you use fg without specifying a job, the last active one is assumed.

Kills off job 1. bash will report the job information, which will look like this:

bash is only asking the job to quit, and sometimes a job will not want to do so. If the job doesn’t terminate, you can add the -KILL[1] option to kill to stop asking and start demanding. For example:

[1] Many people use the signal number -9 instead of the signal name -KILL. However, it’s technically more portable to use the signal name.