These classnotes are depreciated. As of 2005, I no longer teach the classes. Notes will remain online for legacy purposes

UNIX01/Init-Getty-Login-Shell

Classnotes | UNIX01 | RecentChanges | Preferences

Last time we looked at init. We learned that init was the master process from which all processes were spawned. Just this morning, we looked at programs to control init.

However, there is a very important step missing between when init runs and when you can actually start using your UNIX box.

GETTY

Recall that

"TTY" comes from the industry-wide abbreviation for "Teletype" since original Unix computers used these devices for input and output.

A TTY today is simply some sort of I/O device for interfacing with your UNIX box (this is a bit of an over-exaggeration... but for the purposes of this class, it's okay).

GETTY is a program that is invoked by init. It is the second process in series that ultimately connects a user with the UNIX system. Usually getty outputs the contents of /etc/issue (which can contain introductory messages about the system) and then starts login sessions for the user to connect. These login sessions will then spawn the shell whenever a user connects. This procedure is generally refered to as init-getty-login-shell and has been a common mantra throughout UNIX history. If there is ever a problem connecting to a UNIX system as a user, then one of these four elements is to blame.

getty is spawned by init based upon entries inside the /etc/inittab file (which is to be expected). When it is invoked, it is generally given a baud rate (connection speed) and a device name to use (one of /dev/tty1, /dev/tty2, etc.). For example, the following is a possible entry from /etc/inittab

 # /sbin/getty invocations for the runlevels.
 #
 # The "id" field MUST be the same as the last
 # characters of the device (after "tty").
 #
 # Format:
 #  <id>:<runlevels>:<action>:<process>
 1:12345:respawn:/sbin/getty 38400 tty1
 2:2345:respawn:/sbin/getty 38400 tty2
 3:2345:respawn:/sbin/getty 38400 tty3
 4:2345:respawn:/sbin/getty 38400 tty4
 5:2345:respawn:/sbin/getty 38400 tty5
 6:2345:respawn:/sbin/getty 38400 tty6

Note that here, the first field of inittab, the "id", must be the same as the device specification. Or "1" must correlate to "tty1" and so on. Also note that the first invocation (id "1") runs at all non-halt/reboot modes including "single user", whereas the others do not. This is because, when booting into single user mode for maintenance, you will need one and only one terminal.

mingetty

mingetty is an alternative to getty which is most often employed on Red Hat and Red Hat-based systems. It's only real difference is that it is not suitable for other, more arbitrary, terminal connections (such as serial line connections.) It's format inside of inittab is not much different than getty. It simply lacks the baud rate:
 # Run gettys in standard runlevels
 1:12345:respawn:/sbin/mingetty tty1
 2:2345:respawn:/sbin/mingetty tty2
 3:2345:respawn:/sbin/mingetty tty3
 4:2345:respawn:/sbin/mingetty tty4
 5:2345:respawn:/sbin/mingetty tty5
 6:2345:respawn:/sbin/mingetty tty6


Classnotes | UNIX01 | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited August 9, 2003 12:11 am (diff)
Search:
(C) Copyright 2003 Samuel Hart
Creative Commons License
This work is licensed under a Creative Commons License.