Include -Wunreachable-code when building.
[sysvinit.git] / man / shutdown.8
CommitLineData
a74aeac6
PR
1'\" -*- coding: UTF-8 -*-
2.\" Copyright (C) 1998-2003 Miquel van Smoorenburg.
3.\"
4.\" This program is free software; you can redistribute it and/or modify
5.\" it under the terms of the GNU General Public License as published by
6.\" the Free Software Foundation; either version 2 of the License, or
7.\" (at your option) any later version.
8.\"
9.\" This program is distributed in the hope that it will be useful,
10.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
11.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12.\" GNU General Public License for more details.
13.\"
14.\" You should have received a copy of the GNU General Public License
15.\" along with this program; if not, write to the Free Software
16.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17.\"
18.\"{{{}}}
19.\"{{{ Title
20.TH SHUTDOWN 8 "November 12, 2003" "" "Linux System Administrator's Manual"
21.\"}}}
22.\"{{{ Name
23.SH NAME
24shutdown \- bring the system down
25.\"}}}
26.\"{{{ Synopsis
27.SH SYNOPSIS
28.B /sbin/shutdown
cd8b8a4b 29.RB [ \-akrhPHfFnc ]
a74aeac6
PR
30.RB [ \-t
31.IR sec ]
a74aeac6 32.I time
cd8b8a4b 33.RI [ "warning message" ]
a74aeac6
PR
34.\"}}}
35.\"{{{ Description
36.SH DESCRIPTION
37\fBshutdown\fP brings the system down in a secure way. All logged-in users are
38notified that the system is going down, and \fBlogin\fP(1) is blocked.
39It is possible to shut the system down immediately or after a specified delay.
40All processes are first notified that the system is going down by the
41signal \s-2SIGTERM\s0. This gives programs like \fBvi\fP(1)
42the time to save the file being edited,
43mail and news processing programs a chance to exit cleanly, etc.
44\fBshutdown\fP does its job by signalling the \fBinit\fP process,
45asking it to change the runlevel.
46Runlevel \fB0\fP is used to halt the system, runlevel \fB6\fP is used
47to reboot the system, and runlevel \fB1\fP is used to put to system into
48a state where administrative tasks can be performed; this is the default
49if neither the \fI-h\fP or \fI-r\fP flag is given to \fBshutdown\fP.
50To see which actions are taken on halt or reboot see the appropriate
51entries for these runlevels in the file \fI/etc/inittab\fP.
52.\"}}}
53.\"{{{ Options
54.SH OPTIONS
55.\"{{{ -a
56.IP "\fB\-a\fP
57Use \fB/etc/shutdown.allow\fP.
58.\"}}}
a74aeac6
PR
59.\"{{{ -k
60.IP \fB\-k\fP
61Don't really shutdown; only send the warning messages to everybody.
62.\"}}}
63.\"{{{ -r
64.IP \fB\-r\fP
65Reboot after shutdown.
66.\"}}}
67.\"{{{ -h
68.IP \fB\-h\fP
69Halt or power off after shutdown.
70.\"}}}
a74aeac6
PR
71.\"{{{ -P
72.IP \fB\-P\fP
73Halt action is to turn off the power.
74.\"}}}
cd8b8a4b
PR
75.\"{{{ -H
76.IP \fB\-H\fP
77Modifier to the -h flag. Halt action is to halt or drop into boot
78monitor on systems that support it. Must be used with the -h flag.
a74aeac6
PR
79.\"}}}
80.\"{{{ -f
81.IP \fB\-f\fP
82Skip fsck on reboot.
83.\"}}}
84.\"{{{ -F
85.IP \fB\-F\fP
86Force fsck on reboot.
87.\"}}}
cd8b8a4b
PR
88.\"{{{ -n
89.IP \fB\-n\fP
90[DEPRECATED] Don't call \fBinit\fP(8) to do the shutdown but do it ourself.
91The use of this option is discouraged, and its results are not always what
92you'd expect.
93.\"}}}
a74aeac6
PR
94.\"{{{ -c
95.IP \fB\-c\fP
55f242bf
DWF
96Cancel a waiting shutdown. ("shutdown now" is no longer waiting.) With
97this option it is of course not possible to give the time argument, but
98you can enter explanatory message arguments on the command line that
99will be sent to all users.
a74aeac6 100.\"}}}
cd8b8a4b
PR
101.\"{{{ -t sec
102.IP "\fB\-t\fP \fIsec\fP"
103Tell \fBinit\fP(8) to wait \fIsec\fP seconds between sending processes the
104warning and the kill signal, before changing to another runlevel.
105.\"}}}
a74aeac6
PR
106.\"{{{ time
107.IP \fItime\fP
108When to shutdown.
109.\"}}}
110.\"{{{ warning-message
cd8b8a4b 111.IP "\fIwarning message\fP"
a74aeac6
PR
112Message to send to all users.
113.\"}}}
114.PP
115The \fItime\fP argument can have different formats. First, it can be an
116absolute time in the format \fIhh:mm\fP, in which \fIhh\fP is the hour
117(1 or 2 digits) and \fImm\fP is the minute of the hour (in two digits).
118Second, it can be in the format \fB+\fP\fIm\fP, in which \fIm\fP is the
119number of minutes to wait. The word \fBnow\fP is an alias for \fB+0\fP.
120.PP
121If shutdown is called with a delay, it will create the advisory file
122.I /etc/nologin
123which causes programs such as \fIlogin(1)\fP to not allow new user
124logins. This file is created five minutes before the shutdown sequence
125starts. Shutdown removes this file if it is stopped before it
126can signal init (i.e. it is cancelled or something goes wrong).
127It also removes it before calling init to change the runlevel.
128.PP
129The \fB\-f\fP flag means `reboot fast'. This only creates an advisory
130file \fI/fastboot\fP which can be tested by the system when it comes
131up again. The boot rc file can test if this file is present, and decide not
132to run \fBfsck\fP(1) since the system has been shut down in the proper way.
133After that, the boot process should remove \fI/fastboot\fP.
134.PP
135The \fB\-F\fP flag means `force fsck'. This only creates an advisory
136file \fI/forcefsck\fP which can be tested by the system when it comes
137up again. The boot rc file can test if this file is present, and decide
138to run \fBfsck\fP(1) with a special `force' flag so that even properly
139unmounted file systems get checked.
140After that, the boot process should remove \fI/forcefsck\fP.
141.PP
142The \fB-n\fP flag causes \fBshutdown\fP not to call \fBinit\fP,
143but to kill all running processes itself.
144\fBshutdown\fP will then turn off quota, accounting, and swapping
145and unmount all file systems.
146.\"}}}
147.\"{{{ Files
148.SH ACCESS CONTROL
149\fBshutdown\fP can be called from \fBinit\fP(8) when the magic keys
150\fBCTRL-ALT-DEL\fP are pressed, by creating an appropriate entry in
151\fI/etc/inittab\fP. This means that everyone who has physical access
152to the console keyboard can shut the system down. To prevent this,
153\fBshutdown\fP can check to see if an authorized user is logged in on
154one of the virtual consoles. If \fBshutdown\fP is called with the \fB-a\fP
155argument (add this to the invocation of shutdown in /etc/inittab),
156it checks to see if the file \fI/etc/shutdown.allow\fP is present.
157It then compares the login names in that file with the list of people
158that are logged in on a virtual console (from \fI/var/run/utmp\fP). Only
159if one of those authorized users \fBor root\fP is logged in, it will
160proceed. Otherwise it will write the message
161.sp 1
162.nf
163\fBshutdown: no authorized users logged in\fP
164.fi
165.sp 1
166to the (physical) system console. The format of \fI/etc/shutdown.allow\fP
167is one user name per line. Empty lines and comment lines (prefixed by a
168\fB#\fP) are allowed. Currently there is a limit of 32 users in this file.
169.sp 1
170Note that if \fI/etc/shutdown.allow\fP is not present, the \fB-a\fP
171argument is ignored.
172.SH HALT OR POWEROFF
173The \fB-H\fP option just sets the \fIinit\fP environment variable
174\fIINIT_HALT\fP to \fIHALT\fP, and the \fB-P\fP option just sets
175that variable to \fIPOWEROFF\fP. The shutdown script that calls
176\fBhalt\fP(8) as the last thing in the shutdown sequence should
177check these environment variables and call \fBhalt\fP(8) with
178the right options for these options to actually have any effect.
179Debian 3.1 (sarge) supports this.
180.SH FILES
181.nf
182/fastboot
183/etc/inittab
184/etc/init.d/halt
185/etc/init.d/reboot
186/etc/shutdown.allow
187.fi
188.\"}}}
189.SH NOTES
190A lot of users forget to give the \fItime\fP argument
191and are then puzzled by the error message \fBshutdown\fP produces. The
192\fItime\fP argument is mandatory; in 90 percent of all cases this argument
193will be the word \fBnow\fP.
194.PP
195Init can only capture CTRL-ALT-DEL and start shutdown in console mode.
196If the system is running the X window System, the X server processes
197all key strokes. Some X11 environments make it possible to capture
198CTRL-ALT-DEL, but what exactly is done with that event depends on
199that environment.
200.PP
201Shutdown wasn't designed to be run setuid. /etc/shutdown.allow is
202not used to find out who is executing shutdown, it ONLY checks who
203is currently logged in on (one of the) console(s).
204.\"{{{ Author
205.SH AUTHOR
206Miquel van Smoorenburg, miquels@cistron.nl
207.\"}}}
208.\"{{{ See also
209.SH "SEE ALSO"
210.BR fsck (8),
211.BR init (8),
212.BR halt (8),
213.BR poweroff (8),
214.BR reboot (8)
215.\"}}}