Advanced Shells and Shell Scripting
In this section, we will look at some of the more advanced things you can do with your trusty shell, the Linux command-line interpreters.
Setting Terminal Attributes
setterm is a command that sets various characteristics of your terminal (say, each virtual console), such as the keyboard repeat rate, tab stops, and text colors.
Most people use this command to change the colors for each virtual console. In this way, you can tell which virtual console you're currently looking at based on the text color. (Notice that this only applies to the virtual consoles in text mode. X11 windows with shells in them are configured differently.)
For example, to change the color of the current terminal to white text on a blue background, use the command:
$ setterm -foreground white -background blueSome programs and actions cause the terminal attributes to be reset to their default values. In order to store the current set of attributes as the default, use:
$ setterm -storesetterm provides many options (most of which you will probably never use). See the setterm(1) manual page or use setterm -help for more information.
If your terminal settings get really messed up (as happens, for example, if you try to look at the contents of a binary file with cat), you can try typing setterm -reset blindly, which should reset your terminal to reasonable settings.
Shell Programming
In "Shells," earlier in this chapter, we discussed the various shells available for Linux, but shells can ...