If you have started several background processes (also named jobs) from the same
shell, the jobs command gives you an overview of the jobs. It also shows the job
number in brackets and their status:
tux@linux:~> jobs
[1] Running okular book.opensuse.startup-xep.pdf &
[2]- Running okular book.opensuse.reference-xep.pdf &
[3]+ Stopped man jobs
To bring a job to the foreground again, enter fg
job_number
.
Whereas job only shows the background processes started from a specic shell, the
ps command (run without options) shows a list of all your processes—those you
started. Find an example output below:
tux@linux:~> ps
PID TTY TIME CMD
15500 pts/1 00:00:00 bash
28214 pts/1 00:00:00 okular
30187 pts/1 00:00:00 kwrite
30280 pts/1 00:00:00 ps
In case a program cannot be terminated in the normal way, use the kill command
to stop the process (or processes) belonging to that program. To do so, specify the
process ID (PID) shown by the output of ps. For example, to shut down the KWrite
editor in the example above, enter
kill 30187
This sends a TERM signal that instructs the program to shut itself down.
Alternatively, if the program or process you want to terminate is a background job
and is shown by the jobs command, you can also use the kill command in combi-
nation with the job number to terminate this process. When identifying the job with
the job number, you must prex the number with a percent character (%):
kill %
job_number
If kill does not help—as is sometimes the case for “runaway” programs—try
kill -9
PID
This sends a KILL signal instead of a TERM signal, bringing the specied process to
an end in most cases.
This section is intended to introduce the most basic set of commands for handling
jobs and processes. Find an overview for system administrators in Section “Processes”
(Chapter 13, System Monitoring Utilities, ↑Reference).
Shell Basics 105