init(1M) init(1M)
NAME
init, telinit - process control initialization
SYNOPSIS
/sbin/init [0123456SsQqabc]
/sbin/telinit [0123456SsQqabc]
DESCRIPTION
init
init is a general process spawner. Its primary role is to create
processes from information stored in the file /etc/inittab [see
inittab(4)].
At any given time, the system is in one of eight possible run levels.
A run level is a software configuration of the system under which only
a selected group of processes exist. The processes spawned by init for
each of these run levels is defined in /etc/inittab. init can be in
one of eight run levels, 0-6 and S or s (run levels S and s are ident-
ical). The run level changes when a privileged user runs /sbin/init.
This user-spawned init sends appropriate signals to the original init
spawned by the operating system when the system was booted, telling it
the run level to which it should change.
The following are the arguments to init.
0 Shut the machine down so it is safe to remove the power.
1 Put the system in system administrator mode. All file systems are
mounted. Only a small set of essential kernel processes are left
running. This mode is for administrative tasks such as installing
optional utility packages. All files are accessible and no users
are logged in on the system.
2 Put the system in multiuser mode. All multiuser environment ter-
minal processes and daemons are spawned. This state is commonly
referred to as the multiuser state.
3 Start the remote file sharing processes and daemons. Mount and
advertise remote resources. Run level 3 extends multiuser mode
and is known as the remote-file-sharing state.
4 Is available to be defined as an alternative multiuser environ-
ment configuration. It is not necessary for system operation and
is usually not used.
5 Stop the Reliant UNIX system and switch to the SASH (stand-alone
shell) [for RM600] in the PROM monitor [for RM400].
6 Stop the Reliant UNIX system and reboot to the state defined by
the initdefault entry in /etc/inittab.
Page 1 Reliant UNIX 5.44 Printed 11/98
init(1M) init(1M)
a, b, c
Process only those /etc/inittab entries having the a, b, or c run
level set. These are pseudo-states, which may be defined to run
certain commands, but which do not cause the current run level to
change.
Q, q Re-examine /etc/inittab.
S, s Enter singleuser mode. When this occurs, the terminal which exe-
cuted this command becomes the system console. This is the only
run level that doesn't require the existence of a properly for-
matted /etc/inittab file. If this file does not exist, then by
default the only legal run level that init can enter is the
singleuser mode. If this file exists, init looks for commands in
/etc/inittab pertaining to singleuser state. When the system
comes up to S or s, file systems for users' files are not mounted
and only essential kernel processes are running. When the system
comes down to S or s, all mounted file systems remain mounted,
and all processes started by init that should only be running in
multiuser mode are killed. In addition, any process that has a
utmp entry will be killed. This last condition insures that all
port monitors started by the SAC are killed and all services
started by these port monitors, including ttymon login services,
are killed. Other processes not started directly by init will
remain running. For example, cron remains running.
When a Reliant UNIX system is booted, init is invoked and the follow-
ing occurs. First, init looks in /etc/inittab for the initdefault
entry [see inittab(4)]. If there is one, init will usually use the run
level specified in that entry as the initial run level to enter. If
there is no initdefault entry in /etc/inittab, init requests that the
user enter a run level from the virtual system console. If an S or s
is entered, init goes to the singleuser state. In the singleuser state
the virtual console terminal is assigned to the user's terminal and is
opened for reading and writing. The command /sbin/su is invoked and a
message is generated on the physical console saying where the virtual
console has been relocated. Use either init or telinit, to signal init
to change the run level of the system. Note that if the shell is ter-
minated (via an end-of-file), init will only re-initialize to the
singleuser state if the /etc/inittab file does not exist.
If a 0 through 6 is entered, init enters the corresponding run level.
Run levels 0, 5, and 6 are reserved states for shutting the system
down. Run levels 2, 3, and 4 are available as multiuser operating
states.
If this is the first time since power up that init has entered a run
level other than singleuser state, init first scans /etc/inittab for
boot and bootwait entries [see inittab(4)]. These entries are per-
formed before any other processing of /etc/inittab takes place, pro-
viding that the run level entered matches that of the entry. In this
way any special initialization of the operating system, such as
Page 2 Reliant UNIX 5.44 Printed 11/98
init(1M) init(1M)
mounting file systems, can take place before users are allowed onto
the system. init then scans /etc/inittab and executes all other
entries that are to be processed for that run level.
To spawn each process in /etc/inittab, init reads each entry and for
each entry that should be respawned, it forks a child process. After
it has spawned all of the processes specified by /etc/inittab, init
waits for one of its descendant processes to die, a powerfail signal,
or a signal from another init or telinit process to change the
system's run level. When one of these conditions occurs, init re-
examines /etc/inittab. New entries can be added to /etc/inittab at any
time; however, init still waits for one of the above three conditions
to occur before re-examining /etc/inittab. To get around this, init Q
or init q command wakes init to re-examine /etc/inittab immediately.
When init comes up at boot time and whenever the system changes from
the singleuser state to another run state, init sets the ioctl(2)
states of the virtual console to those modes saved in the file
/etc/ioctl.syscon. This file is written by init whenever the
singleuser state is entered.
When a run level change request is made init sends the warning signal
(SIGTERM) to all processes that are undefined in the target run level.
init waits five seconds before forcibly terminating these processes
via the kill signal (SIGKILL).
When init receives a signal telling it that a process it spawned has
died, it records the fact and the reason it died in /var/adm/utmp and
/var/adm/wtmp if it exists [see who(1)]. A history of the processes
spawned is kept in /var/adm/wtmp. If /var is not accessible, then init
records this information in temporary files in /stand and saves this
information when /var becomes accessible (no information is lost).
If init receives a powerfail signal (SIGPWR) it scans /etc/inittab for
special entries of the type powerfail and powerwait. These entries are
invoked (if the run levels permit) before any further processing takes
place. In this way init can perform various cleanup and recording
functions during the powerdown of the operating system.
telinit
telinit, which is linked to /sbin/init, is used to direct the actions
of init. It takes a one-character argument and signals init to take
the appropriate action.
DIAGNOSTICS
If init finds that it is respawning an entry from /etc/inittab more
than ten times in two minutes, it will assume that there is an error
in the command string in the entry, and generate an error message on
the system console. It will then refuse to respawn this entry until
either five minutes has elapsed or it receives a signal from a user-
spawned init or telinit. This prevents init from eating up system
resources when someone makes a typographical error in the inittab file
Page 3 Reliant UNIX 5.44 Printed 11/98
init(1M) init(1M)
or a program is removed that is referenced in /etc/inittab.
When attempting to boot the system, failure of init to prompt for a
new run level may be because the virtual system console is linked to a
device other than the physical system console.
NOTES
init and telinit can be run only by a privileged user.
init returns from singleuser state without /var being mounted. Typi-
cally, init executes a script of the form /sbin/rcN to go into state N
(via /etc/inittab). These scripts execute scripts of the form
/etc/rcN.d/[KS]*. /sbin/rcN scripts have been modified to recognize an
error status of 100 from the /etc/rcN.d/[KS]* scripts as a major
failure and cause the system to go into singleuser mode.
The S or s state must not be used indiscriminately in the /etc/inittab
file. A good rule to follow when modifying this file is to avoid
adding this state to any line other than the initdefault. However,
this varies from site to site. More items may be done in singleuser
state by updating /etc/inittab with proper entries, for example
/sbin/rcS for site-specific singleuser state script.
If a default state is not specified in the initdefault entry in
/etc/inittab, state 0 is entered. The system then switches off.
If the utmp file cannot be created in the /var filesystem when booting
the system, a utmp file is created in the /stand file system. This is
later moved to the /var file system when it is mounted. This happens
transparently to the system administrator. The same result is achieved
whether the /var filesystem is mounted or not when booting the system.
If the system allows kernel to pass boot-time arguments to init (main
init), the following arguments can be passed.
-l # The -l option takes a number which denotes the init run-
level. It accepts only: 123456sS, and defaults to singleuser
if any other value is specified.
-s, -S Go to singleuser level.
-a Ask for new level, ignoring level defined by the initdefault
entry in /etc/inittab.
-n A new shell is created before going into any level. If used
with the singleuser level, this happens much before
singleuser mode is entered and can be used to repair things
by the system administrator.
Page 4 Reliant UNIX 5.44 Printed 11/98
init(1M) init(1M)
-x # This avoids the debug level, causing init to append entries
in /etc/debug. This file is always appended and not removed
by init. The file should be removed once init is debugged,
or after modifying entries in /etc/inittab.
-v # This sets INITVERBOSE=1 in global environment for children
of init.
FILES
/etc/inittab
/var/adm/utmp
/var/adm/wtmp
/etc/ioctl.syscon
/dev/console
SEE ALSO
login(1), sh(1), stty(1), who(1), ttymon(1M), shutdown(1M), kill(2),
inittab(4), utmp(4), utmpx(4), termio(7).
Page 5 Reliant UNIX 5.44 Printed 11/98