Running Multiple Programs Background Operations

Even in text mode, you can run multiple programs in Linux. One tool for doing this is the ampersand operator (&). Append this character to the end of a command and Linux launches the program in the background; the program runs, but you retain control of the terminal from which you launched the program. Of course, this action makes more sense for some programs than for others—launching a text-mode text editor in this way doesn't make much sense, for instance, because you need to interact with the program. A program that just processes data and doesn't produce any console output, though, may be profitably launched in the background. You could launch dd in this way, for instance, to copy a floppy disk image to a file while still retaining control of your console:

You can also launch X programs in this way; when so launched, the program doesn't take over your xterm window, although it may still direct some output to thexterm. If you omit the ampersand, you can't use the xterm window until the X program finishes its work.

Once a program is running, you can usually kick it into the background by pressing Ctrl+Z. The program suspends operations (it stops whatever it was doing, even if it was a CPU-intensive computation), and you can type new commands at your shell. Typing bg at this point puts the program in the background, much as if you'd launched it with an ampersand. Typing fg brings the program back to the foreground.

0 0

Post a comment