.\"{{{}}} .\"{{{ Title .TH INIT 8 "May 06, 1996" "" "Linux System Administrator's Manual" .\"}}} .\"{{{ Name .SH NAME init, telinit \- process control initialization .\"}}} .\"{{{ Synopsis .SH SYNOPSIS .B /sbin/init .RB [ " \-t sec " ] .RB [ " 0123456SsQq " ] .br .B /sbin/telinit .RB [ " \-t sec " ] .RB [ " 0123456sSQqabc " ] .\"}}} .\"{{{ Description .SH DESCRIPTION .\"{{{ init .SS Init .B Init is the father of all processes. Its primary role is to create processes from a script stored in the file \fB/etc/inittab\fP (see \fIinittab\fP(5)). This file usually has entries which cause \fBinit\fP to spawn \fBgetty\fPs on each line that users can log in. It also controls autonomous processes required by any particular system. .PP A \fIrun level\fP is a software configuration of the system which allows only a selected group of processes to exist. The processes spawned by \fBinit\fP for each of these \fIrun levels\fP are defined in the \fB/etc/inittab\fP file. \fBInit\fP can be in one of eight \fIrun level\fPs, \fB0\(en6\fP and \fBS\fP or \fBs\fP. The \fIrun level\fP is changed by having a privileged user run \fB/sbin/telinit\fP, which sends appropriate signals to \fBinit\fP, telling it which run level to change to. .PP After \fBinit\fP is invoked as the last step of the kernel booting, it looks for the file \fB/etc/inittab\fP to see if there is an entry of the type \fBinitdefault\fP (see \fIinittab\fP(5)). \fBinitdefault\fP determines the initial run level of the system. If there is no such entry or no \fB/etc/inittab\fP at all, a \fIrun level\fP has to be entered at the system console. .PP \fIRun level\fP \fBS\fP or \fBs\fP bring the system to single user mode and do not require an \fB/etc/initttab\fP file. In single user mode, \fB/bin/sh\fP is invoked on \fB/dev/console\fP. .PP When entering single user mode, \fBinit\fP reads the console's \fIioctl\fP(2) states from \fB/etc/ioctl.save\fP. If this file does not exist, \fBinit\fP initializes the line at \fB9600 baud\fP and with \fBCLOCAL\fP settings. When \fBinit\fP leaves single user mode, it stores the console's \fIioctl\fP settings in this file so it can re-use them for the next single-user session. .PP When entering a multi user mode the first time, \fBinit\fP performs the \fBboot\fP and \fBbootwait\fP entries to allow file systems to be mounted before users can log in. Then all entries matching the \fIrun level\fP are processed. .PP When starting a new process, \fBinit\fP first looks if the file \fI/etc/initscript\fP exists. If it does, it uses this script to start the process. .PP Each time a child terminates, \fBinit\fP records the fact and the reason it died in \fB/var/run/utmp\fP and \fB/var/log/wtmp\fP if these files exist. .PP After it has spawned all of the processes specified, \fBinit\fP waits for one of its descendant processes to die, a powerfail signal, or until it is signaled by \fB/sbin/telinit\fP to change the system's \fIrun level\fP. When one of the above three conditions occurs, it re-examines the \fB/etc/inittab\fP file. New entries can be added to this file at any time. However, \fBinit\fP still waits for one of the above three conditions to occur. To provide for an instantaneous response, the \fBQ\fP or \fBq\fP command can wake up \fBinit\fP to re-examine the \fB/etc/inittab\fP file. .PP If \fBinit\fP is not in single user mode and receives a powerfail signal, special powerfail entries are invoked. .PP When \fBinit\fP is requested to change the \fIrun level\fP, it sends the warning signal \s-1\fBSIGTERM\fP\s0 to all processes that are undefined in the new \fIrun level\fP. It then waits 5 seconds before forcibly terminating these processes via the kill signal \s-1\fBSIGKILL\fP\s0. Note that \fBinit\fP assumes that all these processes (and their descendants) remain in the same process group which \fBinit\fP originally created for them. If any process changes its process group affiliation it will not receive these signals. Such processes need to be terminated separately. .\"}}} .\"{{{ telinit .SS telinit \fB/sbin/telinit\fP is linked to \fB/sbin/init\fP. It takes a one-character argument and signals \fBinit\fP to perform the appropriate action. The following arguments serve as directives to \fB/sbin/telinit\fP: .IP "\fB0\fP,\fB1\fP,\fB2\fP,\fB3\fP,\fB4\fP,\fB5\fP or \fB6\fP" tell \fB/sbin/init\fP to switch to the specified run level. .IP \fBa\fP,\fBb\fP,\fBc\fP tell \fB/sbin/init\fP to process only those \fB/etc/inittab\fP file entries having \fIrun level\fP \fBa\fP,\fBb\fP or \fBc\fP. .IP "\fBQ\fP or \fBq\fP" tells \fB/sbin/init\fP to re-examine the \fB/etc/inittab\fP file. .IP "\fBS\fP or \fBs\fP" tells \fB/sbin/init\fP to switch to single user mode. .PP \fB/sbin/telinit\fP can also tell init how much time it should wait between sending processes the TERM and the KILL signal; default this is 5 seconds, but it can be changed by the \fB-t sec\fP option. .PP \fB/sbin/telinit\fP can be invoked only by users with appropriate privileges. .\"}}} .\"}}} .\"{{{ Runlevels .SH RUNLEVELS Run levels \fB0, 1 and 6\fP are reserved. Runlevel 0 is used to halt the system, runlevel 6 is used to reboot the system and runlevel 1 is used to get the system down into single user mode. Runlevel \fBS\fP is not really ment to use directly, but more for the scripts that are executed when entering runlevel \fB1\fP.For more information on this, see the manpages for \fBshutdown\fP(1) and \fBinittab\fP(5). .PP Runlevels 7-9 are also valid, though not really documented. This is because "traditional" Unix variants don't use them. In case you wonder, runlevels \fIS\fP and \fIs\fP are in fact the same. Internally they are aliases for the same runlevel - this is just a leftover from the systems the author used to use when writing sysvinit. .\"}}} .\"{{{ Files .SH FILES .nf /etc/inittab /etc/initscript /dev/console /etc/ioctl.save /var/run/utmp /var/log/wtmp /dev/initctl .fi .\"}}} .SH ENVIRONMENT Init sets the following environment variables for all its children: .IP \fBPATH\fP Defaults to \fI/bin:/usr/bin:\fP .IP \fBINIT_VERSION\fP As the name says. Useful to determine if a script runs directly from init. .IP \fBRUNLEVEL\fP The current system runlevel. .IP \fBPREVLEVEL\fP The previous runlevel (useful after a runlevel switch). .\"{{{ Conforming to .SH BOOTFLAGS It is possible to pass a number of flags to init from the boot monitor (eg. LILO). Init accepts the following flags: .TP 0.5i .B S, single Single user mode boot. In this mode \fI/etc/inittab\fP is examined and the bootup rc scripts are usually run before the single user mode shell is started. .PP .TP 0.5i .B 1-5 Runlevel to boot into. .PP .TP 0.5i .B -b, emergency Boot directly into a single user shell without running any other startup scripts. .PP .SH CONFORMING TO \fBInit\fP is compatible with the System V init. It works closely together with the scripts in the directories \fI/etc/init.d\fP and \fI/etc/rc{runlevel}.d\fP. If your systems uses this convention, there should be a \fIREADME\fP file in the directory /etc/init.d explaining how these scripts work. .\"}}} .\"{{{ Warnings .SH WARNINGS \fBInit\fP assumes that processes and descendants of processes remain in the same process group which was originally created for them. If the processes change their group, \fBinit\fP can't kill them and you may end up with two processes reading from one terminal line. .\"}}} .\"{{{ Diagnostics .SH DIAGNOSTICS If \fB/sbin/init\fP finds that it is continuously respawning an entry more than 10 times in 2 minutes, it will assume that there is an error in the command string, generate an error message on the system console, and refuse to respawn this entry until either 5 minutes has elapsed or it receives a signal. This prevents it from eating up system resources when someone makes a typographical error in the \fB/etc/inittab\fP file or the program for the entry is removed. .\"}}} .\"{{{ Author .SH AUTHOR Miquel van Smoorenburg (miquels@cistron.nl), initial manual page by Michael Haardt (u31b3hs@pool.informatik.rwth-aachen.de). .\"}}} .\"{{{ See also .SH "SEE ALSO" getty(1), login(1), sh(1), who(1), shutdown(1), kill(2), inittab(5), initscript(5), utmp(5) .\"}}}