UNIX allows you run as many programs concurrently as you wish. At any time, you can have one program running in foreground with which you can interact, and any number of others running in background.
Unlike some operating systems (eg Microsoft Windows), UNIX gives each active program its fair slice of processor time whether it be in foreground or background. Processor time is doled out to each program in turn by the operating system. UNIX does not depend on each program obediently returning control every so often to let its neighbours have a go.
Programs are therefore written as simple single-task processes which are run, interrrupted, then continued according to a regular cycle.
Interactive programs like editors are simply parked in a frozen state when in background. This is simply because they are not receiving any stimulus from their only input source, the console keyboard when they are in background mode. Programs which respond to events from sources other than the console carry on running as normal in background mode.
To launch a program in background mode, you type your command with an & at the end:
If you have started a program in foreground and want to stop it, then switch it to background, or re-start it in foreground later, you type the following:
|Ctrl-Z ||to stop the current foreground program
|fg ||to re-start it in foreground again
|bg ||to re-start it in background mode
Programs running in background are referred to as jobs. A single job can be made up of many processes, eg:
To find out what jobs are running in background, type:
 - Stopped (signal) elm
 + Stopped edit file1
 - Running prog1 file2 file3
The + indicates the job that was most recently-started or stopped.
|bg %job||restarts the job in background
|fg %job||restarts the job in foreground (the fg not necessary)
|kill %job||kills the job completely
For the word job you can substitute one of the following:
- the job number shown in 
- enough of the the program name (eg elm) to identify it uniquely
- % to refer to the most recently started/stopped job (type %%)
Background Programs and the Terminal
A background program cannot read from the keyboard. If it needs to do so, it stops. Its status is shown as follows:
 - Stopped (tty input) elm
Your options in this case are to type:
|%%||to pull it into foreground
|kill %%||to get rid of it
Full-screen programs are designed to save the screen when they are stopped and re-draw it when they are re-started.
To prevent or allow a background program overwriting the screen, type:
|stty tostop||to stop background programs writing to screen
|stty -tostop||to enable them to write to the screen.
© 1998 Robert John Morton