Main index

Introducing UNIX and Linux


Advanced shell programming

Overview
Sending and trapping signals
      Signal names
Functions
Aliases
The 'exec' mechanism
The 'eval' mechanism
Sending data across networks
      Sending printable characters
      Splitting files
Makefiles
Safe programming
Setting up a terminal
More on files
Miscellaneous utilities
Summary
Exercises

Setting up a terminal

We have assumed that your system administrator has set up your terminal and the system so that the terminal will work. This is a very reasonable expectation, but sometimes you may need to communicate with a UNIX machine from an unusual terminal that has not been set up for you. If you have a problem with your terminal, then in the normal course of events it can be corrected using tput; this will not help though if the system does not already have all the information it needs about the terminal.

The command stty is used to specify to the UNIX system the characteristics both of the terminal and of the communication device linking the terminal and the system. However, be careful using stty - mistakes may be difficult to correct. Clearly, if you cannot communicate at all with the UNIX system, stty is of no use to you. If you can get the system as far as reading a line containing stty, you are then in a position to correct such things as the size of terminal screen that UNIX thinks you have, which control characters are matched to which keys, and so on. Try this command with option -a to display the current settings for your terminal. You will get several lines of output, which will look something like:

stty -a
speed 9600 baud; rows 25; columns 80; line = 2; intr = ^C;
...
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
...

In this instance, the terminal has 25 rows and 80 columns and communicates with the processors at 9600 baud (baud is 'bits per second'). The keystroke necessary to send an interrupt signal SIGINT is ctrl-C. Look at the manual page for stty to discover the meaning of the other information it displays. In order to change any of the settings, follow stty by the setting you wish to change and its new value. For example, to cause your terminal to have a width of only 30 character columns, you should type:

stty columns 30

If you try this example, remember to reset the terminal to its original settings afterwards.


Copyright © 2002 Mike Joy, Stephen Jarvis and Michael Luck