599 601




Linux Unleashed, Third Edition:Devices





-->















Previous
Table of Contents
Next




What Are /sbin/getty and /etc/gettydefs?
The sbin/getty (/etc/getty on some systems) program is referred to quite a lot when dealing with terminals, but people often don’t clearly understand what the program does. Quite simply, /sbin/getty is a binary program that sets the communications parameters between Linux and a terminal, including the speed, protocol, and any special handling of the cable.
The /sbin/getty program is called by /etc/init when a user is logging in. When called, /sbin/getty opens the serial port or other connection to the terminal and sets the communications parameters based on information in the file /etc/gettydefs (getty definitions). The getty process then generates the login prompt on the remote terminal.
Many special handling and command options are available with the getty process, but most of them are of little interest to users and casual system administrators. If you want complete information on the getty command, consult the man pages that accompany Linux.
The /etc/gettydefs file is used to supply the settings getty uses for communications. The format of each line in the gettydefs file is as follows:


label:initial flags: final flags: login prompt: next label


The label is used to identify each line, so that when /sbin/getty is started with an argument (as it usually is, transparent to the user), the argument is used to match the label and provide the configuration information. The initial and final flags are used to set any behavior for the connection before and after the login program has executed.
The login prompt: is the prompt to be displayed on the terminal. Usually it is just login:, but it can be any string. Finally, the next label is used to send getty to another line, in case it can’t use the current one. This is typically used with modem lines, which start at a high speed (such as 9600 baud) and go to 4800, 2400, and 1200 in sequence, trying to connect at each step. For terminals, the next label is usually a pointer back to the line’s first label.
An extract from a sample /etc/gettydefs file looks like this:


console# B19200 OPOST ONLCR TAB3 BRKINT IGNPAR ISTRIP IXON IXANY PARENB
ECHO
ECHOE ECHOK ICANON ISIG CS8 CREAD # B19200 OPOST ONLCR TAB3 BRKINT IGNPAR
ISTRIP
IXON IXANY PARENB ECHO ECHOE ECHOK ICANON ISIG CS8 CREAD #Console Login:
#console

9600H# B9600 # B9600 SANE IXANY PARENB TAB3 HUPCL #login: #4800H

4800H# B4800 # B4800 SANE IXANY PARENB TAB3 HUPCL #login: #2400H

2400H# B2400 # B2400 SANE IXANY PARENB TAB3 HUPCL #login: #1200H

1200H# B1200 # B1200 SANE IXANY PARENB TAB3 HUPCL #login: #300H

300H# B300 # B300 SANE IXANY PARENB TAB3 HUPCL #login: #9600H


If you look at the file that accompanies your Linux system, you see that there are many more lines, but they all have the same format as the preceding examples. The easiest lines to look at are the shorter ones (the last five lines in the preceding extract), but they all have the same format as the preceding examples.

These lines are for a modem, starting at 9600 baud. The initial flag is set to B9600, which sets the baud rate at 9600 baud. The final flags, used when a connection has been established, set the characteristics of the line (such as a TAB meaning three spaces). Finally, the field at the end points to the next lower speed to provide checks for slower modems or poor lines that prevent fast logins.
The first line in the preceding extract is typical for a terminal. It sets many initial and final flags that control how the terminal behaves. The reference at the end of the line is back to the same definition, because the terminal is hard-wired to the system.

Note:  You shouldn’t have to change the entries in the gettydefs file, because the default file contains many different configurations. You should examine the file carefully to find an entry that works with the terminal you are using. If you do make changes to the gettydefs file, you should run the command getty -c gettydefs to make the changes effective.





Previous
Table of Contents
Next














Wyszukiwarka