xref: /csrg-svn/sbin/init/init.8 (revision 69707)
161500Sbostic.\" Copyright (c) 1980, 1991, 1993
261500Sbostic.\"	The Regents of the University of California.  All rights reserved.
318883Smckusick.\"
460435Sbostic.\" This code is derived from software contributed to Berkeley by
560435Sbostic.\" Donn Seeley at Berkeley Software Design, Inc.
660435Sbostic.\"
748834Scael.\" %sccs.include.redist.roff%
818883Smckusick.\"
9*69707Smckusick.\"     @(#)init.8	8.6 (Berkeley) 05/26/95
1048834Scael.\"
1148834Scael.Dd
1248834Scael.Dt INIT 8
1348834Scael.Os BSD 4
1448834Scael.Sh NAME
1548834Scael.Nm init
1648834Scael.Nd process control initialization
1748834Scael.Sh SYNOPSIS
1848834Scael.Nm init
1948834Scael.Sh DESCRIPTION
2048834ScaelThe
2148834Scael.Nm init
2248834Scaelprogram
2348834Scaelis the last stage of the boot process.
2448834ScaelIt normally runs the automatic reboot sequence as described in
2548834Scael.Xr reboot 8 ,
2618883Smckusickand if this succeeds, begins multi-user operation.
2758427SmckusickIf the reboot scripts fail,
2861022Smckusick.Nm init
2958427Smckusickcommences single user operation by giving
3048834Scaelthe super-user a shell on the console.
3148834ScaelThe
3248834Scael.Nm init
3358427Smckusickprogram may be passed parameters
3418883Smckusickfrom the boot program to
3548834Scaelprevent the system from going multi-user and to instead execute
3658427Smckusicka single user shell without starting the normal daemons.
3748834ScaelThe system is then quiescent for maintenance work and may
3858427Smckusicklater be made to go to multi-user by exiting the
3961022Smckusicksingle-user shell (with ^D).
4048834ScaelThis
4148834Scaelcauses
4248834Scael.Nm init
4348834Scaelto run the
4448834Scael.Pa /etc/rc
4558427Smckusickstart up command file in fastboot mode (skipping disk checks).
4648834Scael.Pp
4758427SmckusickIf the
4858427Smckusick.Nm console
4958427Smckusickentry in the
5058427Smckusick.Xr ttys 5
5158427Smckusickfile is marked ``insecure'',
5258427Smckusickthen
5358427Smckusick.Nm init
5458427Smckusickwill require that the superuser password be
5558427Smckusickentered before the system will start a single-user shell.
5658427SmckusickThe password check is skipped if the
5758427Smckusick.Nm console
5858427Smckusickis marked as ``secure''.
5958427Smckusick.Pp
6058427SmckusickThe kernel runs with four different levels of security.
6158427SmckusickAny superuser process can raise the security level, but only
6258427Smckusick.Nm init
6358427Smckusickcan lower it.
6458427SmckusickSecurity levels are defined as follows:
6558427Smckusick.Bl -tag -width flag
6658427Smckusick.It Ic -1
6758427SmckusickPermanently insecure mode \- always run system in level 0 mode.
6858427Smckusick.It Ic 0
6958427SmckusickInsecure mode \- immutable and append-only flags may be turned off.
7058427SmckusickAll devices may be read or written subject to their permissions.
7158427Smckusick.It Ic 1
7258427SmckusickSecure mode \- immutable and append-only flags may not be changed;
7358427Smckusickdisks for mounted filesystems,
7458427Smckusick.Pa /dev/mem ,
7558427Smckusickand
7658427Smckusick.Pa /dev/kmem
7758427Smckusickare read-only.
78*69707SmckusickThe
79*69707Smckusick.Xr settimeofday 2
80*69707Smckusicksystem call can only advance the time.
8158427Smckusick.It Ic 2
8258427SmckusickHighly secure mode \- same as secure mode, plus disks are always
8358427Smckusickread-only whether mounted or not.
8458427SmckusickThis level precludes tampering with filesystems by unmounting them,
8558427Smckusickbut also inhibits running
8658427Smckusick.Xr newfs 8
8758427Smckusickwhile the system is multi-user.
8858427Smckusick.El
8958427Smckusick.Pp
9058427SmckusickNormally, the system runs in level 0 mode while single user
9158427Smckusickand in level 1 mode while multiuser.
9258427SmckusickIf the level 2 mode is desired while running multiuser,
9358427Smckusickit can be set in the startup script
9458427Smckusick.Pa /etc/rc
9558427Smckusickusing
9666844Sbostic.Xr sysctl 8 .
9758427SmckusickIf it is desired to run the system in level 0 mode while multiuser,
9858427Smckusickthe administrator must build a kernel with the variable
9958427Smckusick.Nm securelevel
10066888Smckusickdefined in the file
10166888Smckusick.Pa /sys/compile/MACHINE/param.c
10266888Smckusickand initialize it to -1.
10358427Smckusick.Pp
10418883SmckusickIn multi-user operation,
10548834Scael.Nm init
10648834Scaelmaintains
10748834Scaelprocesses for the terminal ports found in the file
10861022Smckusick.Xr ttys 5 .
10948834Scael.Nm Init
11048834Scaelreads this file, and executes the command found in the second field.
11148834ScaelThis command is usually
11248834Scael.Xr getty 8 ;
11348834Scael.Xr getty
11448834Scaelopens and initializes the tty line
11518883Smckusickand
11648834Scaelexecutes the
11748834Scael.Xr login
11848834Scaelprogram.
11918883SmckusickThe
12048834Scael.Xr login
12148834Scaelprogram, when a valid user logs in,
12258427Smckusickexecutes a shell for that user.  When this shell
12348834Scaeldies, either because the user logged out
12458427Smckusickor an abnormal termination occurred (a signal),
12548834Scaelthe
12648834Scael.Nm init
12748834Scaelprogram wakes up, deletes the user
12848834Scaelfrom the
12948834Scael.Xr utmp 5
13048834Scaelfile of current users and records the logout in the
13148834Scael.Xr wtmp
13248834Scaelfile.
13348834ScaelThe cycle is
13448834Scaelthen restarted by
13548834Scael.Nm init
13658427Smckusickexecuting a new
13748834Scael.Xr getty
13848834Scaelfor the line.
13967324Sah.pl +1
14048834Scael.Pp
14161022SmckusickLine status (on, off, secure, getty, or window information)
14261022Smckusickmay be changed in the
14348834Scael.Xr ttys
14448834Scaelfile without a reboot by sending the signal
14548834Scael.Dv SIGHUP
14648834Scaelto
14748834Scael.Nm init
14848834Scaelwith the command
14969031Sbostic.Dq Li "kill \-s HUP 1" .
15058427SmckusickOn receipt of this signal,
15148834Scael.Nm init
15248834Scaelre-reads the
15348834Scael.Xr ttys
15448834Scaelfile.
15561022SmckusickWhen a line is turned off in
15661022Smckusick.Xr ttys ,
15748834Scael.Nm init
15861022Smckusickwill send a SIGHUP signal to the controlling process
15961022Smckusickfor the session associated with the line.
16061022SmckusickFor any lines that were previously turned off in the
16148834Scael.Xr ttys
16261085Smckusickfile and are now on,
16348834Scael.Nm init
16448834Scaelexecutes a new
16561022Smckusick.Xr getty
16661085Smckusickto enable a new login.
16761022SmckusickIf the getty or window field for a line is changed,
16861085Smckusickthe change takes effect at the end of the current
16961022Smckusicklogin session (e.g., the next time
17061022Smckusick.Nm init
17161022Smckusickstarts a process on the line).
17261022SmckusickIf a line is commented out or deleted from
17361022Smckusick.Xr ttys ,
17461022Smckusick.Nm init
17561022Smckusickwill not do anything at all to that line.
17661085SmckusickHowever, it will complain that the relationship between lines
17761085Smckusickin the
17861085Smckusick.Xr ttys
17961085Smckusickfile and records in the
18061085Smckusick.Xr utmp
18161085Smckusickfile is out of sync,
18261022Smckusickso this practice is not recommended.
18348834Scael.Pp
18448834Scael.Nm Init
18518883Smckusickwill terminate multi-user operations and resume single-user mode
18648834Scaelif sent a terminate
18748834Scael.Pq Dv TERM
18848834Scaelsignal, for example,
18969031Sbostic.Dq Li "kill \-s TERM 1" .
19058427SmckusickIf there are processes outstanding that are deadlocked (because of
19118883Smckusickhardware or software failure),
19248834Scael.Xr init
19318883Smckusickwill not wait for them all to die (which might take forever), but
19418883Smckusickwill time out after 30 seconds and print a warning message.
19548834Scael.Pp
19648834Scael.Nm Init
19718883Smckusickwill cease creating new
19848834Scael.Xr getty Ns 's
19948834Scaeland allow the system to slowly die away, if it is sent a terminal stop
20048834Scael.Pq Dv TSTP
20148834Scaelsignal, i.e.
20269031Sbostic.Dq Li "kill \-s TSTP 1" .
20348834ScaelA later hangup will resume full
20458427Smckusickmulti-user operations, or a terminate will start a single user shell.
20518883SmckusickThis hook is used by
20648834Scael.Xr reboot 8
20718883Smckusickand
20848834Scael.Xr halt 8 .
20948834Scael.Pp
21048834ScaelThe role of
21148834Scael.Nm init
21248834Scaelis so critical that if it dies, the system will reboot itself
21318883Smckusickautomatically.
21418883SmckusickIf, at bootstrap time, the
21548834Scael.Xr init
21661022Smckusickprocess cannot be located, the system will panic with the message
21761022Smckusick``panic: "init died (signal %d, exit %d)''.
21848834Scael.Sh DIAGNOSTICS
21948834Scael.Bl -diag
22061022Smckusick.It "getty repeating too quickly on port %s, sleeping"
22128561SkarelsA process being started to service a line is exiting quickly
22228561Skarelseach time it is started.
22328561SkarelsThis is often caused by a ringing or noisy terminal line.
22461022Smckusick.Em "Init will sleep for 10 seconds" ,
22548834Scael.Em "then continue trying to start the process" .
22648834Scael.Pp
22761022Smckusick.It "some processes would not die; ps axl advised."
22848834ScaelA process
22918883Smckusickis hung and could not be killed when the system was shutting down.
23058427SmckusickThis condition is usually caused by a process
23158427Smckusickthat is stuck in a device driver because of
23258427Smckusicka persistent device error condition.
23348834Scael.El
23448834Scael.Sh FILES
23548834Scael.Bl -tag -width /var/log/wtmp -compact
23648834Scael.It Pa /dev/console
23748834ScaelSystem console device.
23848834Scael.It Pa /dev/tty*
23948834ScaelTerminal ports found in
24048834Scael.Xr ttys .
24148834Scael.It Pa /var/run/utmp
24248834ScaelRecord of Current users on the system.
24348834Scael.It Pa /var/log/wtmp
24448834ScaelRecord of all logins and logouts.
24548834Scael.It Pa /etc/ttys
24648834ScaelThe terminal initialization information file.
24748834Scael.It Pa /etc/rc
24848834ScaelSystem startup commands.
24948834Scael.El
25048834Scael.Sh SEE ALSO
25148834Scael.Xr login 1 ,
25248834Scael.Xr kill 1 ,
25348834Scael.Xr sh 1 ,
25448834Scael.Xr ttys 5 ,
25548834Scael.Xr crash 8 ,
25648834Scael.Xr getty 8 ,
25748834Scael.Xr rc 8 ,
25848834Scael.Xr reboot 8 ,
25948834Scael.Xr halt 8 ,
26048834Scael.Xr shutdown 8
26148834Scael.Sh HISTORY
26248834ScaelA
26348834Scael.Nm
26448834Scaelcommand appeared in
26548834Scael.At v6 .
26661085Smckusick.Sh BUGS
26761085SmckusickSystems without
26861085Smckusick.Xr sysctl
26961085Smckusickbehave as though they have security level \-1.
270