Home > Help Files > Unix > Login Help > Login general

Login: General


Setting Terminal Types

Initialization files allow you to execute commands automatically, every time you log in, or every time you start up a new shell. Each time you log in, it is a good idea to identify your terminal to the system, for this allows you to use many programs more effectively. You may also set your erase character to something other than the default DEL, and also change your interrupt character to something other than control-C.

The C shell recognizes two initialization files in an account's home directory: ".cshrc", which is read by each shell (including subshells created to execute shell scripts, or to escape from the editor), and ".login", which is processed once, when you first log in. At login time, the .cshrc file is read first, and the .login file second. The C shell does not recognize the ".start_up" file, formerly used with version 6, or the ".profile" file, used by the Bourne shell.

Typically, ".login" contains commands to identify the terminal and set the erase character, while ".cshrc" is used for setting shell variables and establishing command aliases. In addition, either file (but not both files) can be used for specifying a command search path other than the standard one. The remainder of this writeup will describe how to identify your terminal to the system, and how to set your erase character. For more information about command search paths, type "help searchpath".

Types of Terminals When terminals were hard-wired to a particular UNIX system, the computer could be told what kind of terminal was connected to each line. However, it is impossible for the computer to know your terminal type when you are coming in over a dialup line. In these cases you need to set the terminal type yourself. Before describing how to automate this process with commands in your ".login" file, we need to cover some background information.

There are over one hundred different kinds of terminals that will work with "vi" and other UNIX programs. Here are codes for some of the more common terminal types:

  • vt100 standard emulation for most terminals
  • xterm standard for xsessions
  • dtterm Common Desktop Environment
  • unknown (if all else fails)

If your terminal is not listed above, first try to find out if there is a code for it in the system's terminal capability file:

grep "weird terminal" /etc/termcap

The terminals in 1111 Etcheverry Hall are all type "dtterm", but can also be set to "vt100".

Setting your Terminal Type from the Shell

If you are already logged in and want to use "vi", then this command will set things up properly:

% set noglob
% eval `tset -s xterm`
% unset noglob

This assumes, of course, that you are using a "xterm" terminal. The "eval `tset -s -Q xterm`" tells the shell to evaluate the re-
sult of the command in back quotes (`tset -s -Q xterm`). The "tset" command sets UNIX to the kind of terminal you are using and performs
any initialization that might be required. The "-s" option tells "tset" to output environment commands to the shell, which allow for quick initialization of many programs. The "set noglob" and "unset noglob" turns off and on, respectively, the shell's global expansion routines.

Setting Your Terminal Automatically

Since it would be inconvenient to have to type these commands every time you log in (and especially to have to remember to type them), it is useful to put them in your ".login" file. The following line, taken from above, can be placed at the beginning of your ".login" file, and identify your terminal to the shell.

set noglob
eval `tset -s -Q -m:\?xterm`
unset noglob

The only differences between this command and the one given before are the options given to the "tset" command. First, the option "-Q" (note
the upper case) tells "tset" to be quiet about what it is doing, and not to print the "Erase set to ..., kill set to ..." message on the screen every time you log in (if you like this message, do not type the "-Q" part of the line in your .login file). Finally, "-m:\?xterm" tells "tset" to prompt for the correct terminal type when you log in. The "modgraph" part of the line means that the default will be "modgraph" if the person logging in just hits return. The prompt for the terminal type would look something like:

TERM = (xterm)

If you are on a modgraph, simply press return. If not, then you would enter the proper code for your terminal (such as "vt100", or "tvi912c").

CHANGING ERASE, KILL, AND INTERRUPT CHARACTERS

The "tset" command provides for two option flags, "-e" and "-k" which allow for the setting of the erase and kill characters, respectively. They should be on the "tset" command line like the other options, and followed immediately by the character that you want to be the erase character and/or kill character. Since control characters do not reproduce well, UNIX, and especially "tset" and "stty" (mentioned later) use the following notation: a caret (^) (or an up-arrow on some terminals) followed by a letter means "Control-letter". That is, "^H" means control-H, while "^F" means control-F. Therefore, the following command sets the erase character to control-H (by the "-e^H"), and the kill character to control-U (by the "-k^U"):

set noglob
eval `tset -e^H -k^U -s -Q -m:\?xterm`
unset noglob

Finally, a separate command, "stty" (set tty) is available to change the interrupt character to something other than control-C. For example, if you come from CF&O machines, you are probably used to the interrupt character being DEL, not control-C, as it is on Newton by default. If this is indeed the case, and you wish to change it, the following command in your ".login" file will do the job:

stty kill ^?

The notation "^?" in the above line is the same as the "DEL" key, but it is an infinitely more readable form.

Sample Login File

The ".login" file is not used solely for setting up the terminal; it can contain other UNIX commands as well. This ".login" file sets the terminal type and changes the erase character to backspace, as discussed above. It also causes the editor to automatically linenumber your text (the "setenv EXINIT..."), prevents accidental logout with control-D (the "set ignoreeof"), and turns off messages coming to your terminal via the "write" command (the "mesg no" line). Make sure you use single quotes (acute accents) on the EXINIT line, but backquotes (grave accents) on the TERM line.

set noglob
eval `tset -s -m: \?xterm`
unset noglob
setenv EXINIT 'set number'
set ignoreeof

You may also want to set the searchpath, use "date" to print the time, or find out how many users are on the system by including a "who | wc -l" command. To find out more about this, type "help login other".

Standard .login file

For an example of a ".login" file, the standard one distributed for all accounts, type

% cat /usr/skel/.login

For more information on getting "fancy" with the "tset" command, go to the Fancy Login help page.

For more information on other things to do in .login, go to the Login: Other help file.

 


Comments to consult@newton.berkeley.edu
© 1998-2009 UC Regents