Linuxtopia Books - Linux System Administrators Guide -
Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




/etc/inittab file">
NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7">

9.2. Configuring init to start getty: the /etc/inittab file

When it starts up, init reads the /etc/inittab configuration file. While the system is running, it will re-read it, if sent the HUP signal (kill -HUP 1); this feature makes it unnecessary to boot the system to make changes to the init configuration take effect.

The /etc/inittab file is a bit complicated. We'll start with the simple case of configuring getty lines. Lines in /etc/inittab consist of four colon-delimited fields:
The fields are described below. In addition, /etc/inittab can contain empty lines, and lines that begin with a number sign (`#'); these are both ignored.


This identifies the line in the file. For getty lines, it specifies the terminal it runs on (the characters after /dev/tty in the device file name). For other lines, it doesn't matter (except for length restrictions), but it should be unique.


The run levels the line should be considered for. The run levels are given as single digits, without delimiters. (Run levels are described in the next section.)


What action should be taken by the line, e.g., respawn to run the command in the next field again, when it exits, or once to run it just once.


The command to run.

To start a getty on the first virtual terminal (/dev/tty1), in all the normal multi-user run levels (2-5), one would write the following line:
1:2345:respawn:/sbin/getty 9600 tty1
The first field says that this is the line for /dev/tty1. The second field says that it applies to run levels 2, 3, 4, and 5. The third field means that the command should be run again, after it exits (so that one can log in, log out, and then log in again). The last field is the command that runs getty on the first virtual terminal.

Different versions of getty are run differently. Consult your manual page, and make sure it is the correct manual page.

If you wanted to add terminals or dial-in modem lines to a system, you'd add more lines to /etc/inittab, one for each terminal or dial-in line. For more details, see the manual pages init, inittab, and getty.

If a command fails when it starts, and init is configured to restart it, it will use a lot of system resources: init starts it, it fails, init starts it, it fails, init starts it, it fails, and so on, ad infinitum. To prevent this, init will keep track of how often it restarts a command, and if the frequency grows to high, it will delay for five minutes before restarting again.

  Published under the terms of the GNU General Public License Design by Interspire