scripts/bash_aliases: tfix
[man-pages.git] / man2 / reboot.2
blob74e8f5caa66fd1f70e6d8fa0ad140e373ab70762
1 .\" Copyright (c) 1998 Andries Brouwer (aeb@cwi.nl), 24 September 1998
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
26 .\"     Added notes on capability requirements
27 .\"
28 .TH REBOOT 2 2021-03-22 "Linux" "Linux Programmer's Manual"
29 .SH NAME
30 reboot \- reboot or enable/disable Ctrl-Alt-Del
31 .SH SYNOPSIS
32 .nf
33 .RB "/* Since kernel version 2.1.30 there are symbolic names " LINUX_REBOOT_*
34    for the constants and a fourth argument to the call: */
35 .PP
36 .BR "#include <linux/reboot.h>  " \
37 "/* Definition of " LINUX_REBOOT_* " constants */"
38 .BR "#include <sys/syscall.h>   " "/* Definition of " SYS_* " constants */"
39 .B #include <unistd.h>
40 .PP
41 .BI "int syscall(SYS_reboot, int " magic ", int " magic2 ", int " cmd ", void *" arg );
42 .PP
43 /* Under glibc and most alternative libc's (including uclibc, dietlibc,
44    musl and a few others), some of the constants involved have gotten
45 .RB "   symbolic names " RB_* ", and the library call is a 1-argument"
46    wrapper around the system call: */
47 .PP
48 .BR "#include <sys/reboot.h>    " "/* Definition of " RB_* " constants */"
49 .B #include <unistd.h>
50 .PP
51 .BI "int reboot(int " cmd );
52 .fi
53 .SH DESCRIPTION
54 The
55 .BR reboot ()
56 call reboots the system, or enables/disables the reboot keystroke
57 (abbreviated CAD, since the default is Ctrl-Alt-Delete;
58 it can be changed using
59 .BR loadkeys (1)).
60 .PP
61 This system call fails (with the error
62 .BR EINVAL )
63 unless
64 .I magic
65 equals
66 .B LINUX_REBOOT_MAGIC1
67 (that is, 0xfee1dead) and
68 .I magic2
69 equals
70 .B LINUX_REBOOT_MAGIC2
71 (that is, 672274793).
72 However, since 2.1.17 also
73 .B LINUX_REBOOT_MAGIC2A
74 (that is, 85072278)
75 and since 2.1.97 also
76 .B LINUX_REBOOT_MAGIC2B
77 (that is, 369367448)
78 and since 2.5.71 also
79 .B LINUX_REBOOT_MAGIC2C
80 (that is, 537993216)
81 are permitted as values for
82 .IR magic2 .
83 (The hexadecimal values of these constants are meaningful.)
84 .PP
85 The
86 .I cmd
87 argument can have the following values:
88 .TP
89 .B LINUX_REBOOT_CMD_CAD_OFF
90 .RB ( RB_DISABLE_CAD ,
91 0).
92 CAD is disabled.
93 This means that the CAD keystroke will cause a
94 .B SIGINT
95 signal to be
96 sent to init (process 1), whereupon this process may decide upon a
97 proper action (maybe: kill all processes, sync, reboot).
98 .TP
99 .B LINUX_REBOOT_CMD_CAD_ON
100 .RB ( RB_ENABLE_CAD ,
101 0x89abcdef).
102 CAD is enabled.
103 This means that the CAD keystroke will immediately cause
104 the action associated with
105 .BR LINUX_REBOOT_CMD_RESTART .
107 .B LINUX_REBOOT_CMD_HALT
108 .RB ( RB_HALT_SYSTEM ,
109 0xcdef0123; since Linux 1.1.76).
110 The message "System halted." is printed, and the system is halted.
111 Control is given to the ROM monitor, if there is one.
112 If not preceded by a
113 .BR sync (2),
114 data will be lost.
116 .BR LINUX_REBOOT_CMD_KEXEC
117 .RB ( RB_KEXEC ,
118 0x45584543, since Linux 2.6.13).
119 Execute a kernel that has been loaded earlier with
120 .BR kexec_load (2).
121 This option is available only if the kernel was configured with
122 .BR CONFIG_KEXEC .
124 .B LINUX_REBOOT_CMD_POWER_OFF
125 .RB ( RB_POWER_OFF ,
126 0x4321fedc; since Linux 2.1.30).
127 The message "Power down." is printed, the system is stopped,
128 and all power is removed from the system, if possible.
129 If not preceded by a
130 .BR sync (2),
131 data will be lost.
133 .B LINUX_REBOOT_CMD_RESTART
134 .RB ( RB_AUTOBOOT ,
135 0x1234567).
136 The message "Restarting system." is printed, and a default
137 restart is performed immediately.
138 If not preceded by a
139 .BR sync (2),
140 data will be lost.
142 .B LINUX_REBOOT_CMD_RESTART2
143 (0xa1b2c3d4; since Linux 2.1.30).
144 The message "Restarting system with command \(aq%s\(aq" is printed,
145 and a restart (using the command string given in
146 .IR arg )
147 is performed immediately.
148 If not preceded by a
149 .BR sync (2),
150 data will be lost.
152 .BR LINUX_REBOOT_CMD_SW_SUSPEND
153 .RB ( RB_SW_SUSPEND ,
154 0xd000fce1; since Linux 2.5.18).
155 The system is suspended (hibernated) to disk.
156 This option is available only if the kernel was configured with
157 .BR CONFIG_HIBERNATION .
159 Only the superuser may call
160 .BR reboot ().
162 The precise effect of the above actions depends on the architecture.
163 For the i386 architecture, the additional argument does not do
164 anything at present (2.1.122), but the type of reboot can be
165 determined by kernel command-line arguments ("reboot=...") to be
166 either warm or cold, and either hard or through the BIOS.
168 .SS Behavior inside PID namespaces
169 .\" commit cf3f89214ef6a33fad60856bc5ffd7bb2fc4709b
170 .\" see also commit 923c7538236564c46ee80c253a416705321f13e3
171 Since Linux 3.4,
173 .BR reboot ()
174 is called
175 from a PID namespace other than the initial PID namespace
176 with one of the
177 .I cmd
178 values listed below,
179 it performs a "reboot" of that namespace:
180 the "init" process of the PID namespace is immediately terminated,
181 with the effects described in
182 .BR pid_namespaces (7).
184 The values that can be supplied in
185 .I cmd
186 when calling
187 .BR reboot ()
188 in this case are as follows:
190 .BR LINUX_REBOOT_CMD_RESTART ", " LINUX_REBOOT_CMD_RESTART2
191 The "init" process is terminated,
193 .BR wait (2)
194 in the parent process reports that the child was killed with a
195 .B SIGHUP
196 signal.
198 .BR LINUX_REBOOT_CMD_POWER_OFF ", " LINUX_REBOOT_CMD_HALT
199 The "init" process is terminated,
201 .BR wait (2)
202 in the parent process reports that the child was killed with a
203 .B SIGINT
204 signal.
206 For the other
207 .I cmd
208 values,
209 .BR reboot ()
210 returns \-1 and
211 .I errno
212 is set to
213 .BR EINVAL .
214 .SH RETURN VALUE
215 For the values of
216 .I cmd
217 that stop or restart the system,
218 a successful call to
219 .BR reboot ()
220 does not return.
221 For the other
222 .I cmd
223 values, zero is returned on success.
224 In all cases, \-1 is returned on failure, and
225 .I errno
226 is set to indicate the error.
227 .SH ERRORS
229 .B EFAULT
230 Problem with getting user-space data under
231 .BR LINUX_REBOOT_CMD_RESTART2 .
233 .B EINVAL
234 Bad magic numbers or \fIcmd\fP.
236 .B EPERM
237 The calling process has insufficient privilege to call
238 .BR reboot ();
239 the caller must have the
240 .B CAP_SYS_BOOT
241 inside its user namespace.
242 .SH CONFORMING TO
243 .BR reboot ()
244 is Linux-specific,
245 and should not be used in programs intended to be portable.
246 .SH SEE ALSO
247 .BR systemctl (1),
248 .BR systemd (1),
249 .BR kexec_load (2),
250 .BR sync (2),
251 .BR bootparam (7),
252 .BR capabilities (7),
253 .BR ctrlaltdel (8),
254 .BR halt (8),
255 .BR shutdown (8)