1 .\" Copyright (c) 1998 Andries Brouwer (aeb@cwi.nl), 24 September 1998
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
6 .\" Added notes on capability requirements
8 .TH REBOOT 2 2021-03-22 "Linux" "Linux Programmer's Manual"
10 reboot \- reboot or enable/disable Ctrl-Alt-Del
13 .RI ( libc ", " \-lc )
16 .RB "/* Since kernel version 2.1.30 there are symbolic names " LINUX_REBOOT_*
17 for the constants and a fourth argument to the call: */
19 .BR "#include <linux/reboot.h> " \
20 "/* Definition of " LINUX_REBOOT_* " constants */"
21 .BR "#include <sys/syscall.h> " "/* Definition of " SYS_* " constants */"
22 .B #include <unistd.h>
24 .BI "int syscall(SYS_reboot, int " magic ", int " magic2 ", int " cmd ", void *" arg );
26 /* Under glibc and most alternative libc's (including uclibc, dietlibc,
27 musl and a few others), some of the constants involved have gotten
28 .RB " symbolic names " RB_* ", and the library call is a 1-argument"
29 wrapper around the system call: */
31 .BR "#include <sys/reboot.h> " "/* Definition of " RB_* " constants */"
32 .B #include <unistd.h>
34 .BI "int reboot(int " cmd );
39 call reboots the system, or enables/disables the reboot keystroke
40 (abbreviated CAD, since the default is Ctrl-Alt-Delete;
41 it can be changed using
44 This system call fails (with the error
49 .B LINUX_REBOOT_MAGIC1
50 (that is, 0xfee1dead) and
53 .B LINUX_REBOOT_MAGIC2
55 However, since 2.1.17 also
56 .B LINUX_REBOOT_MAGIC2A
59 .B LINUX_REBOOT_MAGIC2B
62 .B LINUX_REBOOT_MAGIC2C
64 are permitted as values for
66 (The hexadecimal values of these constants are meaningful.)
70 argument can have the following values:
72 .B LINUX_REBOOT_CMD_CAD_OFF
73 .RB ( RB_DISABLE_CAD ,
76 This means that the CAD keystroke will cause a
79 sent to init (process 1), whereupon this process may decide upon a
80 proper action (maybe: kill all processes, sync, reboot).
82 .B LINUX_REBOOT_CMD_CAD_ON
86 This means that the CAD keystroke will immediately cause
87 the action associated with
88 .BR LINUX_REBOOT_CMD_RESTART .
90 .B LINUX_REBOOT_CMD_HALT
91 .RB ( RB_HALT_SYSTEM ,
92 0xcdef0123; since Linux 1.1.76).
93 The message "System halted." is printed, and the system is halted.
94 Control is given to the ROM monitor, if there is one.
99 .B LINUX_REBOOT_CMD_KEXEC
101 0x45584543, since Linux 2.6.13).
102 Execute a kernel that has been loaded earlier with
104 This option is available only if the kernel was configured with
107 .B LINUX_REBOOT_CMD_POWER_OFF
109 0x4321fedc; since Linux 2.1.30).
110 The message "Power down." is printed, the system is stopped,
111 and all power is removed from the system, if possible.
116 .B LINUX_REBOOT_CMD_RESTART
119 The message "Restarting system." is printed, and a default
120 restart is performed immediately.
125 .B LINUX_REBOOT_CMD_RESTART2
126 (0xa1b2c3d4; since Linux 2.1.30).
127 The message "Restarting system with command \(aq%s\(aq" is printed,
128 and a restart (using the command string given in
130 is performed immediately.
135 .B LINUX_REBOOT_CMD_SW_SUSPEND
136 .RB ( RB_SW_SUSPEND ,
137 0xd000fce1; since Linux 2.5.18).
138 The system is suspended (hibernated) to disk.
139 This option is available only if the kernel was configured with
140 .BR CONFIG_HIBERNATION .
142 Only the superuser may call
145 The precise effect of the above actions depends on the architecture.
146 For the i386 architecture, the additional argument does not do
147 anything at present (2.1.122), but the type of reboot can be
148 determined by kernel command-line arguments ("reboot=...") to be
149 either warm or cold, and either hard or through the BIOS.
151 .SS Behavior inside PID namespaces
152 .\" commit cf3f89214ef6a33fad60856bc5ffd7bb2fc4709b
153 .\" see also commit 923c7538236564c46ee80c253a416705321f13e3
158 from a PID namespace other than the initial PID namespace
162 it performs a "reboot" of that namespace:
163 the "init" process of the PID namespace is immediately terminated,
164 with the effects described in
165 .BR pid_namespaces (7).
167 The values that can be supplied in
171 in this case are as follows:
173 .BR LINUX_REBOOT_CMD_RESTART ", " LINUX_REBOOT_CMD_RESTART2
174 The "init" process is terminated,
177 in the parent process reports that the child was killed with a
181 .BR LINUX_REBOOT_CMD_POWER_OFF ", " LINUX_REBOOT_CMD_HALT
182 The "init" process is terminated,
185 in the parent process reports that the child was killed with a
200 that stop or restart the system,
206 values, zero is returned on success.
207 In all cases, \-1 is returned on failure, and
209 is set to indicate the error.
213 Problem with getting user-space data under
214 .BR LINUX_REBOOT_CMD_RESTART2 .
217 Bad magic numbers or \fIcmd\fP.
220 The calling process has insufficient privilege to call
222 the caller must have the
224 inside its user namespace.
228 and should not be used in programs intended to be portable.
235 .BR capabilities (7),