📄 init.8
字号:
.\" Copyright (c) 1980, 1991, 1993.\" The Regents of the University of California. All rights reserved..\".\" This code is derived from software contributed to Berkeley by.\" Donn Seeley at Berkeley Software Design, Inc..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\" notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\" notice, this list of conditions and the following disclaimer in the.\" documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\" must display the following acknowledgement:.\" This product includes software developed by the University of.\" California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\" may be used to endorse or promote products derived from this software.\" without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\" @(#)init.8 8.3 (Berkeley) 4/18/94.\".Dd April 18, 1994.Dt INIT 8.Os BSD 4.Sh NAME.Nm init.Nd process control initialization.Sh SYNOPSIS.Nm init.Sh DESCRIPTIONThe.Nm initprogramis the last stage of the boot process.It normally runs the automatic reboot sequence as described in.Xr reboot 8 ,and if this succeeds, begins multi-user operation.If the reboot scripts fail,.Nm initcommences single user operation by givingthe super-user a shell on the console.The.Nm initprogram may be passed parametersfrom the boot program toprevent the system from going multi-user and to instead executea single user shell without starting the normal daemons.The system is then quiescent for maintenance work and maylater be made to go to multi-user by exiting thesingle-user shell (with ^D).Thiscauses.Nm initto run the.Pa /etc/rcstart up command file in fastboot mode (skipping disk checks)..PpIf the.Nm consoleentry in the.Xr ttys 5file is marked ``insecure'',then.Nm initwill require that the superuser password beentered before the system will start a single-user shell.The password check is skipped if the .Nm consoleis marked as ``secure''..PpThe kernel runs with four different levels of security.Any superuser process can raise the security level, but only .Nm initcan lower it.Security levels are defined as follows:.Bl -tag -width flag.It Ic -1Permanently insecure mode \- always run system in level 0 mode..It Ic 0Insecure mode \- immutable and append-only flags may be turned off.All devices may be read or written subject to their permissions..It Ic 1Secure mode \- immutable and append-only flags may not be changed;disks for mounted filesystems,.Pa /dev/mem ,and.Pa /dev/kmemare read-only..It Ic 2Highly secure mode \- same as secure mode, plus disks are alwaysread-only whether mounted or not.This level precludes tampering with filesystems by unmounting them,but also inhibits running.Xr newfs 8while the system is multi-user..El.PpNormally, the system runs in level 0 mode while single userand in level 1 mode while multiuser.If the level 2 mode is desired while running multiuser,it can be set in the startup script.Pa /etc/rcusing.Xr sysctl 8 .If it is desired to run the system in level 0 mode while multiuser,the administrator must build a kernel with the variable.Nm secureleveldefined in the file.Pa /sys/compile/MACHINE/param.cand initialize it to -1..PpIn multi-user operation, .Nm initmaintainsprocesses for the terminal ports found in the file.Xr ttys 5 ..Nm Initreads this file, and executes the command found in the second field.This command is usually.Xr getty 8 ;.Xr gettyopens and initializes the tty lineandexecutes the.Xr loginprogram.The.Xr loginprogram, when a valid user logs in,executes a shell for that user. When this shelldies, either because the user logged outor an abnormal termination occurred (a signal),the.Nm initprogram wakes up, deletes the userfrom the.Xr utmp 5file of current users and records the logout in the.Xr wtmpfile.The cycle isthen restarted by.Nm initexecuting a new.Xr gettyfor the line..PpLine status (on, off, secure, getty, or window information)may be changed in the.Xr ttysfile without a reboot by sending the signal.Dv SIGHUPto.Nm initwith the command.Dq Li "kill -HUP 1" .On receipt of this signal,.Nm initre-reads the.Xr ttysfile.When a line is turned off in.Xr ttys ,.Nm initwill send a SIGHUP signal to the controlling processfor the session associated with the line.For any lines that were previously turned off in the.Xr ttysfile and are now on,.Nm initexecutes a new.Xr gettyto enable a new login.If the getty or window field for a line is changed,the change takes effect at the end of the currentlogin session (e.g., the next time .Nm initstarts a process on the line).If a line is commented out or deleted from.Xr ttys ,.Nm initwill not do anything at all to that line.However, it will complain that the relationship between linesin the.Xr ttysfile and records in the.Xr utmpfile is out of sync,so this practice is not recommended..Pp.Nm Initwill terminate multi-user operations and resume single-user modeif sent a terminate.Pq Dv TERMsignal, for example,.Dq Li "kill \-TERM 1" .If there are processes outstanding that are deadlocked (because ofhardware or software failure),.Xr initwill not wait for them all to die (which might take forever), butwill time out after 30 seconds and print a warning message..Pp.Nm Initwill cease creating new.Xr getty Ns 'sand allow the system to slowly die away, if it is sent a terminal stop.Pq Dv TSTPsignal, i.e..Dq Li "kill \-TSTP 1" .A later hangup will resume fullmulti-user operations, or a terminate will start a single user shell.This hook is used by.Xr reboot 8and.Xr halt 8 ..PpThe role of.Nm initis so critical that if it dies, the system will reboot itselfautomatically.If, at bootstrap time, the.Xr initprocess cannot be located, the system will panic with the message``panic: "init died (signal %d, exit %d)''..Sh DIAGNOSTICS.Bl -diag.It "getty repeating too quickly on port %s, sleeping"A process being started to service a line is exiting quicklyeach time it is started.This is often caused by a ringing or noisy terminal line..Em "Init will sleep for 10 seconds" ,.Em "then continue trying to start the process" ..Pp.It "some processes would not die; ps axl advised."A processis hung and could not be killed when the system was shutting down.This condition is usually caused by a processthat is stuck in a device driver because ofa persistent device error condition..El.Sh FILES.Bl -tag -width /var/log/wtmp -compact.It Pa /dev/consoleSystem console device..It Pa /dev/tty*Terminal ports found in.Xr ttys ..It Pa /var/run/utmpRecord of Current users on the system..It Pa /var/log/wtmpRecord of all logins and logouts..It Pa /etc/ttysThe terminal initialization information file..It Pa /etc/rcSystem startup commands..El.Sh SEE ALSO.Xr login 1 ,.Xr kill 1 ,.Xr sh 1 ,.Xr ttys 5 ,.Xr crash 8 ,.Xr getty 8 ,.Xr rc 8 ,.Xr reboot 8 ,.Xr halt 8 ,.Xr shutdown 8.Sh HISTORYA.Nmcommand appeared in.At v6 ..Sh BUGSSystems without.Xr sysctlbehave as though they have security level \-1.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -