When a computer is turned on, many things happen even before an operating system starts. The basic steps that occur each time you start a Linux system are the following:
In the booting process, the transfer from the kernel phase to init is indicated by the following lines (see red lines)
# # 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) # id:5:initdefault: # System initialization. si::sysinit:/etc/rc.d/rc.sysinit l0:0:wait:/etc/rc.d/rc 0 l1:1:wait:/etc/rc.d/rc 1 l2:2:wait:/etc/rc.d/rc 2 l3:3:wait:/etc/rc.d/rc 3 l4:4:wait:/etc/rc.d/rc 4 l5:5:wait:/etc/rc.d/rc 5 l6:6:wait:/etc/rc.d/rc 6 # Trap CTRL-ALT-DELETE 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. pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down" # If power was restored before the shutdown kicked in, cancel it. pr:12345:powerokwait:/sbin/shutdown -c "Power Restored; Shutdown Cancelled" # Run gettys in standard runlevels 1:2345: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 # Run xdm in runlevel 5 x:5:respawn:/etc/X11/prefdm -nodaemonAll non-commented lines in the inittab consists of several colon-separated fields in the format:
id:runlevels:action:command
| Run Level | What happens in this run level |
|---|---|
| 0 | All processes are terminated and the machine comes to an orderly halt. As the inittab comments point out, this is NOT a good choice for initdefault because as soon as the kernel, modules, and drives are loaded, the machine halts. |
| 1, s, S | This is a single-user mode, frequently used for system maintenance and instances where it may be preferable to have few processes running and no services activated. In single-user mode, the network is nonexistent, the X-server is not running, and it is possible that some file systems are not mounted. |
| 2 | Multiuser mode. Multiple logins are allowed, all configured file systems are mounted, and all processes except X, the at daemon, the xinetd daemon, and NIS/NFS are started. If your machine doesn't have a permanent network connection, this is good choice for initdefault. |
| 3 | Multiuser mode with network services. Run level 3 is the typical value for initdefault on Fedora or RHEL server. |
| 4 | Run level 4 is available as a user-defined run level. It is nearly identical to runlevel 3 in a default Fedora or RHEL configuration. |
| 5 | Multiuser mode with network services and X. This run level starts the X server and presents a graphical login window, visually resembling any of the more expensive Unix-based workstations. This is a common initdefault value for a Fedora or RHEL workstation or desktop systems. |
| 6 | All processes are terminated and the machine is gracefully rebooted. Again, it's not a good idea to use this as initdefault value. The effect is a possibly infinite cycle of booting, followed by rebooting. |
| 7, 8, 9 | Generally unused and undefined, these run levels have the potential to meet any needs not covered by the default options. |
| a, b, c, A, B, C | Used in conjunction with the ondemand action. These don't really specify a run level but can launch a program or daemon "on demand" if so instructed. |
During system startup, a series of scripts are run to start the services that you need. These include scripts to start network interfaces, mount directoreis, and monitor your system.Most of these scripts are run from the subdirectoreis of
Shortly, the
Typical location for scripts that start/stop services of software packages is

If you need to reorganize or remove run-level scripts, you have several options. You can use GUI Service Configuration from the System / Administration / Services (or just run system-config-services from shell). You can also use a console interface program ntsysv that basically provides the same functionality.
You can also use the pure command line tool chkconfig. Being used with the option --list this program provides information about the run-levels for all scripts or a particular script (given as a parameter):
$ /sbin/chkconfig --list sshd sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:offThe output shows that sshd daemon is configured to run on levels 2, 3, 4, and 5.
Using the chkconfig command you also can add your own service to the list of services run at startup. This is done with a simple chkcondig --add command providing the name of the script that starts your service as the second argument:
$ chkconfig --add my_daemonBut first you have to make sure that your script satisfies several conditions:
# chkconfig: 345 82 28 # description: This scripts starts MY_DAEMON service # processname: my_daemonThe most important out of these three line is, of course, the first line. The line chkconfig: 345 82 28 sets the service to be started on levels 3, 4, and 5 (parameter 345), give the S-script number 82, and give the K-scripts number 28. Thus, in the directories /etc/rc.d/rc3.d, /etc/rc.d/rc4.d, and /etc/rc.d/rc4.d the file S82my_daemon will be created, and all other run-level directories will contain K28my_daemon file.
If you logged in as the root user, you can change easily determine the current run-level by using the runlevel command:
$ runlevel N 5The output of this command consists of two values. The first one (in the example above it's N) reports the previous run level, whereas the second one (5) tells you the current one.
If you would like to change the current runlevel, you can do this by using either init or telinit command (both located at the /sbin directory.) For example, the init 3 command changes the run-level to level 3.
As a matter of fact, shutting down or rebooting the machine is nothing but changing the run-level. For example, init 0 will shut the system down, while the init 6 command will reboot it. With this in mind, other ways to change the run-level include the reboot, halt, poweroff, and shutdown commands. Please read the manual pages for these commands and discover that they all in fact just one program.
There are a bunch of services, particularly network services, which are not handled by separate run-level scripts. Instead, a single run-level script called xinetd is run to handle incoming requests for these services. For that reason, xinetd is sometime referred to as the super-server.
When a request comes into your computer for a service that xinetd is monitoring, xinetd uses the