Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
init(8)
Edit
PageHistory
Diff
Info
LikePages
!!!INIT !!NAME init, telinit - process control initialization !!SYNOPSIS __/sbin/init__ [[ __-a__ ] [[ __-s__ ] [[ __-b__ ] [[ __-z xxx__ ] [[ __0123456Ss__ ] __/sbin/telinit__ [[ __-t sec__ ] [[__0123456sSQqabcUu__ ] !!DESCRIPTION __Init__ is the parent of all processes. Its primary role is to create processes from a script stored in the file __/etc/inittab__ (see inittab(5)). This file usually has entries which cause __init__ to spawn __getty__s on each line that users can log in. It also controls autonomous processes required by any particular system. !!RUNLEVELS A ''runlevel'' is a software configuration of the system which allows only a selected group of processes to exist. The processes spawned by __init__ for each of these runlevels are defined in the __/etc/inittab__ file. __Init__ can be in one of eight runlevels: __0-6__ and __S__ or __s__. The runlevel is changed by having a privileged user run __telinit__, which sends appropriate signals to __init__, telling it which runlevel to change to. Runlevels __0__, __1__, and __6__ 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 __S__ is not really meant to be used directly, but more for the scripts that are executed when entering runlevel 1. For more information on this, see the manpages for shutdown(8) and inittab(5). Runlevels 7-9 are also valid, though not really documented. This is because S'' and ''s'' are in fact the same. Internally they are aliases for the same runlevel. !!BOOTING After __init__ is invoked as the last step of the kernel boot sequence, it looks for the file __/etc/inittab__ to see if there is an entry of the type __initdefault__ (see inittab(5)). The __initdefault__ entry determines the initial runlevel of the system. If there is no such entry (or no __/etc/inittab__ at all), a runlevel must be entered at the system console. Runlevel __S__ or __s__ bring the system to single user mode and do not require an __/etc/inittab__ file. In single user mode, __/sbin/sulogin__ is invoked on __/dev/console__. When entering single user mode, __init__ reads the console's ioctl(2) states from __/etc/ioctl.save__. If this file does not exist, __init__ initializes the line at __9600 baud__ and with __CLOCAL__ settings. When __init__ leaves single user mode, it stores the console's ''ioctl'' settings in this file so it can re-use them for the next single-user session. When entering a multi-user mode for the first time, __init__ performs the __boot__ and __bootwait__ entries to allow file systems to be mounted before users can log in. Then all entries matching the runlevel are processed. When starting a new process, __init__ first checks whether the file ''/etc/initscript'' exists. If it does, it uses this script to start the process. Each time a child terminates, __init__ records the fact and the reason it died in __/var/run/utmp__ and __/var/log/wtmp__, provided that these files exist. !!CHANGING RUNLEVELS After it has spawned all of the processes specified, __init__ waits for one of its descendant processes to die, a powerfail signal, or until it is signaled by __telinit__ to change the system's runlevel. When one of the above three conditions occurs, it re-examines the __/etc/inittab__ file. New entries can be added to this file at any time. However, __init__ still waits for one of the above three conditions to occur. To provide for an instantaneous response, the __telinit Q__ or __q__ command can wake up __init__ to re-examine the __/etc/inittab__ file. If __init__ is not in single user mode and receives a powerfail signal (SIGPWR), it reads the file __/etc/powerstatus__. It then starts a command based on the contents of this file: F(AIL) Power is failing, UPS is providing the power. Execute the __powerwait__ and __powerfail__ entries. O(K) The power has been restored, execute the __powerokwait__ entries. L(OW) The power is failing and the UPS has a low battery. Execute the __powerfailnow__ entries. If /etc/powerstatus doesn't exist or contains anything else then the letters __F__, __O__ or __L__, init will behave as if it has read the letter __F__. Usage of __SIGPWR__ and __/etc/powerstatus__ is discouraged. Someone wanting to interact with __init__ should use the __/dev/initctl__ control channel - see the source code of the __sysvinit__ package for more documentation about this. When __init__ is requested to change the runlevel, it sends the warning signal __SIGTERM__ to all processes that are undefined in the new runlevel. It then waits 5 seconds before forcibly terminating these processes via the __SIGKILL__ signal. Note that __init__ assumes that all these processes (and their descendants) remain in the same process group which __init__ 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 __/sbin/telinit__ is linked to __/sbin/init__. It takes a one-character argument and signals __init__ to perform the appropriate action. The following arguments serve as directives to __telinit__: __0__,__1__,__2__,__3__,__4__,__5__ or __6__ tell __init__ to switch to the specified run level. __a__,__b__,__c__ tell __init__ to process only those __/etc/inittab__ file entries having runlevel __a__,__b__ or __c__. __Q__ or __q__ tell __init__ to re-examine the __/etc/inittab__ file. __S__ or __s__ tell __init__ to switch to single user mode. __U__ or __u__ tell __init__ to re-execute itself (preserving the state). No re-examining of __/etc/inittab__ file happens. Run level should be one of __Ss12345__, otherwise request would be silently ignored. __telinit__ can also tell __init__ how long it should wait between sending processes the SIGTERM and SIGKILL signals. The default is 5 seconds, but this can be changed with the __-t sec__ option. __telinit__ can be invoked only by users with appropriate privileges. The __init__ binary checks if it is __init__ or __telinit__ by looking at its ''process id''; the real __init__'s process id is always __1__. From this it follows that instead of calling __telinit__ one can also just use __init__ instead as a shortcut. !!ENVIRONMENT __Init__ sets the following environment variables for all its children: __PATH__ ''/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin'' __INIT_VERSION__ As the name says. Useful to determine if a script runs directly from __init__. __RUNLEVEL__ The current system runlevel. __PREVLEVEL__ The previous runlevel (useful after a runlevel switch). __CONSOLE__ The system console. This is really inherited from the kernel; however if it is not set __init__ will set it to __/dev/console__ by default. !!BOOTFLAGS It is possible to pass a number of flags to __init__ from the boot monitor (eg. LILO). __Init__ accepts the following flags: __-s, S, single__ Single user mode boot. In this mode ''/etc/inittab'' is examined and the bootup rc scripts are usually run before the single user mode shell is started. __1-5__ Runlevel to boot into. __-b, emergency__ Boot directly into a single user shell without running any other startup scripts. __-a, auto__ The LILO boot loader adds the word "auto" to the command line if it booted the kernel with the default command line (without user intervention). If this is found init sets the "AUTOBOOT" environment variable to "yes". Note that you cannot use this for any security measures ‐ of course the user could specify "auto" or -a on the command line manually. __-z xxx__ The argument to -z is ignored. You can use this to expand the command line a bit, so that it takes some more space on the stack. __Init__ can then manipulate the command line so that ps(1) shows the current runlevel. !!INTERFACE Init listens on a ''fifo'' in /dev, ''/dev/initctl'', for messages. __Telinit__ uses this to communicate with init. The interface is not very well documented or finished. Those interested should study the ''initreq.h'' file in the ''src/'' subdirectory of the __init__ source code tar archive. !!SIGNALS Init reacts to several signals: __SIGHUP__ Init looks for ''/etc/initrunlvl'' and ''/var/log/initrunlvl.'' If one of these files exist and contain an ASCII runlevel, init switches to the new runlevel. ''This is for backwards compatibility only!'' . In the normal case (the files don't exist) init behaves like __telinit q__ was executed. __SIGUSR1__ On receipt of this signals, init closes and re-opens its control fifo, __/dev/initctl__. Useful for bootscripts when /dev is remounted. __SIGINT__ Normally the kernel sends this signal to init when CTRL-ALT-DEL is pressed. It activates the ''ctrlaltdel'' action. __SIGWINCH__ The kernel sends this signal when the ''!KeyboardSignal'' key is hit. It activates the ''kbrequest'' action. !!CONFORMING TO __Init__ is compatible with the System V init. It works closely together with the scripts in the directories ''/etc/init.d'' and ''/etc/rc{runlevel}.d''. If your system uses this convention, there should be a ''README'' file in the directory ''/etc/init.d'' explaining how these scripts work. !!FILES /etc/inittab /etc/initscript /dev/console /etc/ioctl.save /var/run/utmp /var/log/wtmp /dev/initctl !!WARNINGS __Init__ 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, __init__ can't kill them and you may end up with two processes reading from one terminal line. !!DIAGNOSTICS If __init__ 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 __/etc/inittab__ file or the program for the entry is removed. !!AUTHOR Miquel van Smoorenburg (miquels''@''cistron.nl), initial manual page by Michael Haardt (u31b3hs''@''pool.informatik.rwth-aachen.de). !!SEE ALSO getty(1), login(1), sh(1), runlevel(8), shutdown(8), kill(1), inittab(5), initscript(5), utmp(5) ----
26 pages link to
init(8)
:
update-rc.d(8)
Man8i
sysklogd(8)
console(4)
callback(8)
halt(8)
initscript(5)
klogd(8)
last(1)
pidof(8)
invoke-rc.d(8)
rcS(5)
runlevel(8)
shutdown(8)
sulogin(8)
swapon(8)
update(8)
utmp(5)
wtmp(5)
vhangup(2)
ptrace(2)
SIGHUP
procinfo(8)
inittab(5)
telinit(8)
getty(8)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.