Commands that are non-interactive can be run in the background while
another task is run in the foreground by appending an ampersand
character to the command string. To run an X-window's based clock program
(for example) in the background, while you work on something else in the
foreground, the following command would be entered to display the clock:
xclock &
While you are using the current window for other purposes, the clock will
continue to operate.
A list of all jobs you currently have, with information on their state
(either running or stopped) is available by entering the jobs command.
If you wish to bring a background process into the foreground again, enter:
fg % <jobnumber>
To stop a foreground job, hit the Control-Z keys at the same time.
Only one job can run in the foreground at any time, while many jobs can be
running in the background. To make stopped jobs run in the background, enter:
bg % <jobnumber>
To see all of the processes that you have running, use the ps
command with no arguments. A list will be displayed showing the
process id, the status of the process, and the command that started
the process.
If you start a process that you need to stop, use the process id
in conjunction with the kill command:
kill -KILL <processid>
The kill command terminates the process immediately.
If you wish to terminate a process in the foreground the kill
command doesn't necessarily need to be used. Entering
<ctrl-c> will normally kill a foreground process.