CHAPTER 16 TAKING CONTROL OF THE SYSTEM (Christian web host)
CHAPTER 16 TAKING CONTROL OF THE SYSTEM Tip If you ve ever tried to run a GUI program from the shell, you might have realized that the shell is inaccessible while it s running. Once you quit the GUI program, the control of the shell will be returned to you. By specifying that the program should run in the background with the & (ampersand symbol), you can run the GUI program and still be able to type away and run other commands. You can send several jobs to the background, and each one will be given a different job number. In this case, when you wish to switch into a running job, you can type its number. For example, the following command will switch you to the background job assigned the number 3: %3 You can exit a job that is currently running by pressing Ctrl+Z. It will still be there in the background, but it won t be running (officially, it s said to be sleeping). To restart it, you can switch back to it, as just described. Alternatively, you can restart it but still keep it in the background. For example, to restart job 2 in the background, leaving the shell prompt free for you to enter other commands, type the following: %2 & You can bring the command in the background into the foreground by typing the following: fg When a background job has finished, something like the following will appear at the shell: [1]+ Done unzip myfile.zip Using jobs within the shell can be a good way of managing your workload. For example, you can move programs into the background temporarily while you get on with something else. If you re editing a file in vi, you can press Ctrl+Z to stop the program. It will remain in the background, and you ll be returned to the shell, where you can type other commands. You can then resume vi later on by typing fg or typing %followed by its job number. Summary This chapter has covered taking complete control of your system. We ve looked at what processes are, how they re separate from programs, and how they can be controlled or viewed using programs such as topand ps. In addition, we explored job management under BASH. You saw that you can stop, start, and pause programs at your convenience. In the next chapter, we ll take a look at several tricks and techniques that you can use with the BASH shell to finely hone your command-line skills.