init, telinit - process control initialization
] [ -s
] [ -b
] [ -z
] [ 0123456Ss
[ -t SECONDS
] [ 0123456sSQqabcUu
[ -e VAR
is the parent of all processes. Its primary role is to create
processes from a script stored in the file /etc/inittab
). This file usually has entries which cause init
s on each line that users can log in. It also controls
autonomous processes required by any particular system.
is a software configuration of the system which allows only a
selected group of processes to exist. The processes spawned by init
each of these runlevels are defined in the /etc/inittab
can be in one of eight runlevels: 0–6
). The runlevel is changed by having a privileged user run
, which sends appropriate signals to init
, telling it
which runlevel to change to.
, and 6
are reserved. Runlevel S is
used to initialize the system on boot. When starting runlevel S (on boot) or
runlevel 1 (switching from a multi-user runlevel) the system is entering
``single-user mode'', after which the current runlevel is S. Runlevel 0 is
used to halt the system; runlevel 6 is used to reboot the system.
After booting through S the system automatically enters one of the multi-user
runlevels 2 through 5, unless there was some problem that needs to be fixed by
the administrator in single-user mode. Normally after entering single-user
mode the administrator performs maintenance and then reboots the system.
For more information, see the manpages for shutdown(8)
Runlevels 7-9 are also valid, though not really documented. This is because
"traditional" Unix variants don't use them.
are the same. Internally they are aliases for
the same runlevel.
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
). The initdefault
determines the initial runlevel of the system. If there is no such entry (or
at all), a runlevel must be entered at the system
initialize the system and do not require an
In single user mode, /sbin/sulogin
is invoked on /dev/console
When entering single user mode, init
initializes the consoles stty
settings to sane values. Clocal mode is set. Hardware speed and handshaking
are not changed.
When entering a multi-user mode for the first time, init
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
exists. If it does, it uses this script to start the
Each time a child terminates, init
records the fact and the reason it
died in /var/run/utmp
, provided that these
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
New entries can be added to this file at any time. However, init
waits for one of the above three conditions to occur. To provide for an
instantaneous response, the telinit Q
command can wake up
to re-examine the /etc/inittab
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:
- Power is failing, UPS is providing the power. Execute the powerwait
and powerfail entries.
- The power has been restored, execute the powerokwait entries.
- The power is failing and the UPS has a low battery. Execute the
If /etc/powerstatus doesn't exist or contains anything else then the letters
, init will behave as if it has read the letter
Usage of SIGPWR
is discouraged. Someone
wanting to interact with init
should use the /run/initctl
control channel - see the source code of the sysvinit
package for more
documentation about this.
is requested to change the runlevel, it sends the warning
to all processes that are undefined in the new runlevel.
It then waits 5 seconds before forcibly terminating these processes via the
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
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.
- 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 Ss0123456 otherwise request would be silently ignored.
can 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
to change the environment for processes it
spawns. The argument of -e
is either of the form VAR
which sets variable VAR
to value VAL
, or of the form VAR
(without an equality sign) which unsets variable VAR
can be invoked only by users with appropriate privileges.
binary checks if it is init
at its process id
; the real init
's process id is always
. From this it follows that instead of calling telinit
also just use init
instead as a shortcut.
sets the following environment variables for all its children:
- As the name says. Useful to determine if a script runs directly from
- The current system runlevel.
- The previous runlevel (useful after a runlevel switch).
- The system console. This is really inherited from the kernel; however if
it is not set init will set it to /dev/console by
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
- Runlevel to boot into.
- -b, emergency
- Boot directly into a single user shell without running any other startup
- -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.
Init listens on a fifo
in /run, /run/initctl
, for messages.
uses this to communicate with init. The interface is not very
well documented or finished. Those interested should study the
file in the src/
subdirectory of the init
source code tar archive.
Init reacts to several signals:
- Has the same effect as telinit q.
- On receipt of this signals, init closes and re-opens its control fifo,
- Normally the kernel sends this signal to init when CTRL-ALT-DEL is
pressed. It activates the ctrlaltdel action.
- The kernel sends this signal when the KeyboardSignal key is hit. It
activates the kbrequest action.
is compatible with the System V init. It works closely together with
the scripts in the directories /etc/init.d
. If your system uses this convention, there should
be a README
file in the directory /etc/init.d
these scripts work.
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.
On a Debian system, entering runlevel 1 causes all processes to be killed except
for kernel threads and the script that does the killing and other processes in
its session. As a consequence of this, it isn't safe to return from runlevel 1
to a multi-user runlevel: daemons that were started in runlevel S and are
needed for normal operation are no longer running. The system should be
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.
Miquel van Smoorenburg (firstname.lastname@example.org), initial manual page by Michael