This commit was manufactured by cvs2svn to create tag 'FreeBSD-release/1.0'.
[unix-history] / sbin / init.chmr / init.8
CommitLineData
78ed81a3 1.\" Copyright (c) 1993 Christoph M. Robitschko
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by Christoph M. Robitschko
15.\" 4. The name of the author may not be used to endorse or promote products
16.\" derived from this software withough specific prior written permission
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28.Dd May 20, 1993
29.Dt INIT 8
30.Os 386BSD
31.Sh NAME
32.Nm init
33.Nd ancestor of all user-level processes
34.Sh SYNOPSIS
35.Nm init
36.Op Fl s
37.Op Fl f
38.Op Fl d Ar level
39.Op Fl C Ar file
40.Op Fl S
41.Sh DESCRIPTION
42.Nm init
43is started by the Operating System kernel as the first user-level process
44(PID 1).
45It creates more processes to execute the system startup script
46.Pa /etc/rc
47and enable users to login. If the system startup fails for any reason,
48it gives the system administrator a shell on the console.
49Note that you cannot execute the
50.Nm init
51program directly (except if you are a UNIX kernel, which seems unlikely).
52.Pp
53.Em Options
54.Bl -tag -width Ds -offset indent
55.It Fl s
56Starts a singleuser shell instead of booting the system to multiuser mode
57.It Fl f
58Fast boot. Calls the
59.Pa /etc/rc
60script without the
61.Sy autoboot
62argument, which causes it to skip disk checks
63.It Fl d Ar level
64Sets the debug level to the specified number.
65.It Fl C Ar file
66Causes
67.Nm init
68to read its configuration from file
69.Ar file
70instead of the default /etc/init.conf .
71.It Fl S
72Only checks the configuration file for syntax errors and exits immediately
73afterwards.
74.El
75.Pp
76.Em Singleuser and multiuser modes
77.Bd -filled -offset indent
78.Nm
79knows of two states:
80.Em singleuser
81and
82.Em multiuser
83\&. The normal state is multiuser, where system daemons such as
84.Xr crond 8
85or
86.Xr inetd 8
87are active and the system accepts logins from direct connect ttys (with
88.Xr getty 8
89) and from the network. In singleuser mode, all daemons and user processes
90terminated, and
91.Nm
92starts a shell on the system console. This shell can be used by the
93system manager for administrative purposes. Because no proceses are running
94that have files open, all file systems except the root file system can be
95unmounted.
96.Ed
97.Pp
98.Em System startup and shutdown
99.Bd -filled -offset indent
100When the system is booted, it creates process 1 and executes the file
101.Pa /sbin/init
102in it. The arguments that are given to the kernel are passed on to
103the
104.NM
105program. Unless the
106.Fl s
107flag is specified,
108.Nm
109starts a shell to execute the
110.Pa /etc/rc
111script with the argument
112.Sy "autoboot"
113(Unless the
114.Fl f
115flag is specified, in which case the script is called without arguments).
116This script checks and mounts file systems and starts
117system daemons. If the script fails (exits with a status unequal to zero),
118a shell is started on the console to enable the system administrator to
119cure the problem. When this shell terminates,
120.Nm
121starts over by executing
122.Pa /etc/rc
123again (without arguments). When finally this script terminates with
124an exit status of zero (signalling success),
125.Nm
126starts multiuser mode by reading the file
127.Pa /etc/ttys
128and starting getty processes for the terminals that are marked active
129in this file.
130.Pp
131To bring the system from multiuser to singleuser mode, you can use
132the
133.Xr shutdown 8
134program.
135.Ed
136.Pp
137.Em Signals
138.Bd -filled -offset indent
139The following list of signals is only here for completeness; You should
140not send any signals to
141.Nm init
142directly, but instead use the
143.Xr shutdown 8
144command to perform a state change.
145.Bl -tag -width SIGTERM
146.It SIGTERM
147go to singleuser mode immediately. All processes are terminated, and then
148a singleuser shell is started on the console.
149.It SIGHUP
150Reread the
151.Pa /etc/ttys
152file.
153.It SIGTSTP
154Drain the system. No new processes are created. The only way out of
155this pseudo-state is another SIGHUP or SIGTERM signal.
156.It SIGTTIN
157Re-read the configuration file. Only valid when in Singleuser mode.
158.It SIGUSR1
159Increase debugging level (if debugging is compiled in)
160.It SIGUSR2
161Turn off debugging
162.El
163.Ed
164.Pp
165.Em Configuration
166.Bd -filled -offset indent
167Upon startup,
168.Nm
169reads the file
170.Pa /etc/init.conf
171or the file specified with the
172.Fl C
173option.
174Each line in this file specifies a thing to configure.
175Empty lines and lines with a hash character
176.Sy #
177as the first character are ignored.
178.Bd -literal
179limit LIMIT VALUE
180hlimit LIMIT VALUE
181.Ed
182.Bd -filled -offset indent
183set a soft or hard limit, respectively. LIMIT can be one of
184.Sy cputime ,
185.Sy filesize ,
186.Sy datasize ,
187.Sy stacksize ,
188.Sy coredumpsize ,
189.Sy memoryuse ,
190.Sy memorylocked ,
191.Sy maxproc ,
192.Sy openfiles .
193The VALUE is specified in bytes or seconds. See
194.Xr setrlimit 2
195for more information.
196.Pp
197Note that you cannot raise hard limits.
198Note also that the specified limits are not used for
199.Nm init
200itself, but for all processes it creates.
201.Ed
202.Bd -literal
203setenv VARIABLE "VALUE"
204.Ed
205.Bd -filled -offset indent
206Sets the specified environment-variable VAR with the specified VALUE.
207VALUE can be ommitted. This setting is valid for all processes
208on the system, except
209.Nm init
210itself.
211.Ed
212.Bd -literal
213debug LEVEL
214.Ed
215.Bd -filled -offset indent
216Sets the debug level of init to the specified value. Note that a level
217specified with the
218.Fl d
219option takes precedence over this.
220.Ed
221.Bd -literal
222startup_state { singleuser | multiuser }
223.Ed
224.Bd -filled -offset indent
225Sets the default runlevel to singleuser or multiuser mode, respectively.
226If
227.Fl s
228is specified, it always goes to singleuser mode.
229.Ed
230.Bd -literal
231include "FILE"
232.Ed
233.Bd -filled -offset indent
234Reads further configuration instructions from file "FILE" and continues in the
235current file afterwards. Include commands can be nested up to a level of 50.
236.Ed
237.Bd -literal
238singleusershell "COMMAND"
239.Ed
240.Bd -filled -offset indent
241Lets you specify a command to execute as a singleuser shell. Note that the
242first argument you specify is the 0th argument passed to the program.
243Default is "/bin/sh -".
244.Ed
245.Bd -literal
246singleuserterminal "TYPE"
247.Ed
248.Bd -filled -offset indent
249Lets you specify a terminal type that is passed in the TERM environment
250variable to the singleusershell. Default is "pc3".
251.Ed
252.Bd -literal
253singleuserdevice "DEVICE"
254.Ed
255.Bd -filled -offset indent
256Lets you specify a terminal device where the singleusershell will be started.
257Default is "/dev/console".
258.Ed
259.Bd -literal
260autobootcommand "COMMAND"
261fastbootcommand "COMMAND"
262.Ed
263.Bd -filled -offset indent
264Lets you specify a command that is executed when the system goes to multiuser
265mode. The difference between the two is that autobootcommand is only executed
266when the system starts multiuser mode immediately after boot, and only if
267.Fl f
268has not been specified.
269If the system has already been in singleuser mode or
270.Fl f
271was used, fastbootcommand is used instead. The defaults are
272"/bin/sh sh /etc/rc autoboot" for autobootcommand, and "/bin/sh sh /etc/rc"
273for fastbootcommand.
274.Ed
275.Bd -literal
276timeout shutdown sigterm TIME
277timeout shutdown sigkill TIME
278.Ed
279.Bd -filled -offset indent
280Normally, if you shutdown to singleuser mode,
281.Nm init
282sends a SIGTERM signal to all processes to give them a chance to
283terminate gracefully, waits 10 seconds, then sends a SIGKILL to all
284remaining processes and waits up to 30 seconds. You can change these timeouts
285if you like.
286.Ed
287.Bd -literal
288timeout error-retry TIME
289.Ed
290.Bd -filled -offset indent
291If
292.Nm init
293encouters a serious problem (such as "fork failed" or "out of memory"), it
294does not terminate, but instead continues its work and retries the operation
295at a later time. The default is to retry after 300 seconds.
296.Ed
297.Bd -literal
298respawn checkstatus { yes | no }
299.Ed
300.Bd -filled -offset indent
301Specifies whether
302.Nm init
303should check the termination status of its children, in order to see if these
304children fail (e.g. a getty on a non-existent device). The default is yes,
305but you may want to switch it off if you have programs that don't return any
306useful exit status.
307.Ed
308.Bd -literal
309respawn checktime { yes | no | TIME }
310.Ed
311.Bd -filled -offset indent
312Specifies whether or not
313.Nm init
314should assume that children that did not live longer than TIME seconds
315were failing. The default is yes, which is equivalent to a time of 5 seconds.
3160 is equivalent to no.
317.Ed
318.Sh ENVIRONMENT
319The UNIX kernel sets up the environment for
320.Nm init
321as part of its initialisation.
322Specifically,
323.Nm
324is called without any files open.
325.Sh FILES
326.Bl -tag -width "/etc/init.conf" -compact
327.It Pa /etc/init.conf
328Configuration file for
329.Nm init
330(See
331.Sx DESCRIPTION
332above)
333.It Pa /etc/rc
334System Startup Script
335.It Pa /etc/ttys
336specifies on which terminals to create login processes
337.El
338.Sh DIAGNOSTICS
339.Nm init
340logs all messages via
341.Xr syslogd 8
342with the
343.Sy LOG_DAEMON
344facility.
345If it cannot open a connectoin to a syslogd, it prints the message
346to the console. Fatal errors (such as a segmentaion fault) cause
347the kernel to panic with the message "init died".
348.Sh SEE ALSO
349.Xr rc 8 ,
350.Xr getty 8 ,
351.Xr syslogd 8 ,
352.Xr ttys 5 ,
353.Xr shutdown 8
354.Sh AUTHOR
355This incarnation of
356.Nm init
357was written by Christoph Robitschko for the 386BSD project.
358.Sh BUGS
359\&... should be reported to <chmr@edvz.tu-graz.ac.at>