Text-Terminals on Linux

来源:互联网 发布:简单冒泡排序算法 编辑:程序博客网 时间:2024/06/06 00:09

http://linux.about.com/od/ttl_howto/a/hwtttl15t01.htm



14.1 Getty (used in /etc/inittab)

Introduction to Getty

In order to have a login process run on a serial port (and the terminal connected to it) when the computer starts up (or switches run levels) a getty command must be put into the /etc/inittab file. Running getty from the command line may cause problems (see If getty run from command line: Programs get stopped to see why ). Getty GETs a TTY (a terminal) going.

Each terminal needs its own getty command. There is also at least one getty command for the console in every /etc/inittab file. Find this and put the getty commands for the real terminals next to it. This file may contain sample getty lines for text terminals that are commented out so that all you need to do is to uncomment them (remove the leading #) and change a few arguments.

The arguments which are permitted depend on which getty you use:
Two gettys best for directly connected terminals are:

  • agetty (sometimes just called getty): Very easy to set up. No config files. See agetty
  • getty (part of getty_ps)
Two gettys best for dial-in modems (avoid for directly connected terminals) are:
  • mgetty: the best one for modems; works for terminals too but inferior
  • uugetty: for modems only; part of the getty_ps package
Simple gettys to use if you don't use a real text-terminal. Most Linux users use one of these at their monitor:
  • mingetty
  • fbgetty
  • fgetty
  • rungetty

Your Linux distribution may come with either ps_getty or agetty for text-terminals. Some distributions supply neither. Unfortunately, they often just call it "getty" so you may need to determine which one you have since the arguments you put after it in /etc/inittab differ.

Debian uses agetty (in the util-linux package). RedHat and Fedora used ps_getty which is at: ps_getty

As a last resort to try to determine which getty you have, you might check out its executable code (usually in /sbin). ps_getty has /etc/gettydefs embedded in this code. To search for it, go to /sbin and type:
strings getty | grep getty 
If getty is actually agetty the above will result in nothing.

However if you have agetty typing:
getty -h
should show the options [-hiLmw].

If you don't have the getty you want check other distributions and the alien program to convert between RPM and Debian packages. The source code may be downloaded fromGetty Software.

If you are not using modem control lines (for example if you only use the minimum number of 3 conductors: transmit, receive, and common signal ground) you should let getty know this by using a "local" flag. The format of this depends on which getty you use.

Getty exits after login (and can respawn)

After you log in you will notice (by using "top", "ps -ax", or "ptree") that the getty process is no longer running. What happened to it? Why does getty restart again if your shell is killed? Here's why.

After you type in your user name, getty takes it and calls the login program telling it your user name. The getty process is replaced by the login process. The login process asks for your password, checks it and starts whatever process is specified in your password file. This process is often the bash shell. If so, bash starts and replaces the login process. Note that one process replaces another and that the bash shell process originally started as the getty process. The implications of this will be explained below.

Now in the /etc/inittab file, getty is supposed to respawn (restart) if killed. It says so on the line that calls getty. But if the bash shell (or the login process) is killed, getty respawns (restarts). Why? Well, both the login process and bash are replacements for getty and inherit

License

Text Terminal How-To Index


0 0