-->
Previous Table of Contents Next


Terminal Files: /etc/ttys and /etc/inittab

Terminal configuration information is stored in the files /etc/ttys and /etc/inittab. These files can be modified by any editor. Some menu-driven programs are now appearing that perform changes to the files for you.


Warning:  
Before making any changes to the terminal configuration files, make a safe copy in case the changes aren’t effective and the file can’t be returned to its original state easily. Simply copy the two files to new names such as /etc/tty.original and /etc/inittab.original.

The /etc/ttys file has two columns. The first shows the type of terminal, and the second shows the device name. A typical /etc/ttys file from a new installation of Linux looks like this:


console tty1

console tty2

console tty3

console tty4

console tty5

console tty6

vt100 ttyp0

vt100 ttyp1

vt100 ttyp2

vt100 ttyp3

The terminal type in the first column is used to set the TERM environment variable when you log in, unless you override the value.

The /etc/inittab file is used to set the behavior of each terminal. The format of the /etc/inittab file follows this pattern:


ID:runlevel:action:process

The ID is a one- or two-character string that uniquely identifies the entry. In most cases, this corresponds to the device name, such as 1 for tty1.

The runlevel decides the capabilities of the terminal with the various states that the Linux operating system can be in (run levels vary from 0 to 6, and A, B, and C). If no entry is provided, all runlevels are supported. Multiple runlevels may be mentioned in the field.

The action section shows how to handle the process field. The action field has several valid entries:

boot Runs when inittab is first read
bootwait Runs when inittab is first read
initdefault Sets initial run level
off Terminates the process if it is running
once Starts the process once
ondemand Always keeps the process running (the same as respawn)
powerfail Executes when init gets a power fail signal
powerwait Executes when init gets a power wait signal
sysinit Executes before accessing the console
respawn Always keeps the process running
wait Starts the process once

The action indicates the behavior of the terminal device when the system starts and when a getty process is terminated on it.

A simple /etc/inittab file (taken from an earlier version of Linux for clarity’s sake because the latest version complicates the lines a little) looks like this:


# inittab for Linux

id:1:initdefault:

rc::bootwait:/etc/rc

1:1:respawn:/etc/getty 9600 tty1

2:1:respawn:/etc/getty 9600 tty2

3:1:respawn:/etc/getty 9600 tty3

4:1:respawn:/etc/getty 9600 tty4

The first two lines (after the comment) are used when the system boots. The second line tells the system to run /etc/rc in order to boot. The rest of the lines indicate that a getty process should be started for tty1 through tty4 at 9600 baud.

Terminal Definitions: The /etc/termcap File

The /etc/termcap file holds the instructions for communicating with different terminals. Most terminals that are supported by the operating system have an entry inside this file. The termcap (terminal capabilities) file can be quite large. If you are going to make changes, copy a version to a safe filename first.

The contents of the termcap file are similar to the printer definition file /etc/printcap. Each entry in the termcap file has a name with several variations, as well as a set of codes and values for different terminal characteristics. Because terminals use many different codes for different actions, many codes can be used with some of the more talented terminals.

An extract from a termcap file shows the definitions for two fairly simple terminals, the Wyse 30 and Wyse 85:


w0|wy30-vb|wyse30-vb|wyse 30 Visible bell:\

      :vb=\E‘8\E‘\072\E‘9:\

      :tc=wy30:

wc|wy85|wyse85|Wyse 85 in 80 column mode, vt100 emulation:\

      :is=\E[61”p\E[13l\E>\E[?1l\E[?3l\E[?7h\E[?16l\E[?5W:\

      :co#80:li#24:am:cl=\E[;H\E[2J:bs:cm=\E[%i%d;%dH:nd=2\E[C:up=2\E[A:\

      :ce=\E[0K:cd=\E[0J:so=2\E[7m:se=2\E[m:us=2\E[4m:ue=2\E[m:\

      :ku=\E[A:kd=\E[B:kr=\E[C:kl=\E[D:\

      :kh=\E[H:xn:\

      :im=:CO=\E[?25h:CF=\E[?25l:ic=\E[1@:dc=\E[1P:\

      :dl=\E[1M:al=\E[1L:GS=\EF:GE=\EG:pt:

The meaning of each set of codes is not really of interest to most users and system administrators. You have to start changing or rewriting terminal entries only if you are adding a terminal type that doesn’t exist in the termcap file already.

The terminal characteristics in the /etc/termcap file are used by the /etc/ttys file. The first column of the ttys file gives the default terminal type used to set the TERM environment variable. Essentially, the startup routine uses a pattern-matching utility to find a matching line in the termcap file, and then reads the codes that follow.


Note:  
Most terminals offer multiple emulations. If you can’t find the terminal type in the termcap file, look for an emulation that is supported. It’s easier to emulate a different terminal than to write a termcap entry for a new type.


Previous Table of Contents Next