Previous Page | Next Page

  1. Introduction
  2. About Linux
  3. Installation and getting started
  4. Logging in and out
  5. Basic Linux Commands
  6. Linux Files and File Permissions
  7. Linux Directory Structure
  8. Finding Files
  9. Linux Help
  10. Setting Time
  11. Devices
  12. Tips
  13. Accessing Other Filesystems
  14. Accessing Removable Media
  15. Making and Managing Filesystems
  16. Emergency Filesystems and Procedures
  17. LILO and Runlevels
  18. Init
  19. Environment, Shell Selection, and Startu
  20. Linux Kernel
  21. Package Installation and Printing
  22. Configuration, Logging and CRON
  23. Keys and Terminal Configuration
  24. Sound Configuration
  25. Managing Users
  26. Passwords
  27. Process Control
  28. Configuration and Diagnostic Tools
  29. Overall Configuration
  30. Using PAM
  31. Basic Network Setup
  32. Tools and Terms
  33. Novell and Printing
  34. Inetd Services
  35. Xinetd Services
  36. Other Network Services
  37. FTP and Telnet
  38. Samba
  39. Identd (auth)
  40. X Configuration
  41. X Use
  42. Using X Remotely
  43. X Documentation
  44. DNS
  45. DHCP and BOOTP
  46. Apache
  47. NFS
  48. PPP
  49. Mail
  50. Routing
  51. IP Masquerading
  52. Proxy Servers and ipchains
  53. UUCP
  54. News
  55. NIS
  56. Network Security
  57. Secure Shell
  58. Text Processing
  59. Shell Programming
  60. Emacs
  61. VI
  62. Recommended Reading
  63. Credits

Linux Init Program

The init program is the first program run after your kernel begins running. It is configured with the /etc/inittab file. By modifying your /etc/inittab file, you change your system configuration in the following areas:

  1. Start up system run level.
  2. Specify processes to be executed during system boot.
  3. Specify processes to be run when the specified runlevel is entered.
  4. Specify processes to be run on certain runlevels with actions like respawn so the process is restarted any time it terminates.
  5. Specify certain actions or processes to be run if certain signals or user actions are indicated.

The previous section on LILO explained what runlevels are.

Below is an example inittab file with line numbers added on the left side for reference:

	# inittab       This file describes how the INIT process should set up
	#               the system in a certain run-level.
	#
	# Author:       Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
	#               Modified for RHS Linux by Marc Ewing and Donnie Barnes
	#

	# Default runlevel. The runlevels used by RHS are:
	#   0 - halt (Do NOT set initdefault to this)
	#   1 - Single user mode
	#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
	#   3 - Full multiuser mode
	#   4 - unused
	#   5 - X11
	#   6 - reboot (Do NOT set initdefault to this)
	# 
1)	id:3:initdefault:

	# System initialization.
2)	si::sysinit:/etc/rc.d/rc.sysinit

3)	l0:0:wait:/etc/rc.d/rc 0
4)	l1:1:wait:/etc/rc.d/rc 1
5)	l2:2:wait:/etc/rc.d/rc 2
6)	l3:3:wait:/etc/rc.d/rc 3
7)	l4:4:wait:/etc/rc.d/rc 4
8)	l5:5:wait:/etc/rc.d/rc 5
9)	l6:6:wait:/etc/rc.d/rc 6

	# Things to run in every runlevel.
10)	ud::once:/sbin/update

	# Trap CTRL-ALT-DELETE
11)	ca::ctrlaltdel:/sbin/shutdown -t3 -r now

	# When our UPS tells us power has failed, assume we have a few minutes
	# of power left.  Schedule a shutdown for 2 minutes from now.
	# This does, of course, assume you have powerd installed and your
	# UPS connected and working correctly.  
12)	pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"

	# If power was restored before the shutdown kicked in, cancel it.
13)	pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled"


	# Run gettys in standard runlevels
14)	1:2345:respawn:/sbin/mingetty tty1
15)	2:2345:respawn:/sbin/mingetty tty2
16)	3:2345:respawn:/sbin/mingetty tty3
17)	4:2345:respawn:/sbin/mingetty tty4
18)	5:2345:respawn:/sbin/mingetty tty5
19)	6:2345:respawn:/sbin/mingetty tty6

	# Run xdm in runlevel 5
	# xdm is now a separate service
20)	x:5:respawn:/etc/X11/prefdm -nodaemon

Line number 1 sets the runlevel to 3. Line numbers 3 through 9 will run the startup script /etc/rc.d/rc for the appropriate run level as selected on line 1. Line numbers 14 through 19 spawn login getty programs on 6 virtual terminals. Other lines perform such things as power management and trapping the CTRL-ALT-DEL keystrokes for shutdown. Please see the "How Linux Works CTDP Guide" for further information on the format of the inittab file and what the init program does.