next up previous
Next: Finding out what's running: Up: Introduction to the Linux Previous: Text files and editors:

Background processes (fg and bg)

The programs we've used so far ran instead of our current terminal. Usually we want to start a program like emacs in addition to our command window, and to do this we use the special `&' character.

[phasnip@mijpnb1 ~]$ emacs test.F90 &

This starts the program emacs as a separate process, so it runs at the same time as our terminal. While we're typing commands emacs is still running, taking up a bit of the computer's time and memory. Processes running in addition to the one we're currently using are called background processes, and the one we're currently using is referred to as the foreground process. Linux is a properly multi-tasking OS, which means that it can handle as many background processes as we like, provided the computer has enough memory to cope with all of their demands.

If we're running a foreground process and want to type some commands instead then we can suspend the current program using CTRL-z. This will return us to the command prompt and let us get on with typing commands. To `unsuspend' and return the program to the foreground we use the fg command. Alternatively once we've suspended the process we might decide we actually want to use it at the same time as the terminal, so we can use the background command bg.


next up previous
Next: Finding out what's running: Up: Introduction to the Linux Previous: Text files and editors:
Phil Hasnip 2007-08-23