reboot(2)
๐ reboot(2) โ the "bye bestie" syscall
okay so real talk, this is a page from the System Calls Manual (yes, the real one, section 2, we're in the kernel-adjacent group chat now) and it's all about reboot() โ the call that either restarts your whole entire machine, or turns that Ctrl-Alt-Del keystroke on and off. iconic behavior honestly ๐
โจ NAME โจ
reboot โ reboot, or enable/disable Ctrl-Alt-Del. that's it, that's the whole vibe ๐
๐ LIBRARY ๐
Standard C library (libc, -lc). the classic ๐
๐ซถ SYNOPSIS ๐ซถ
so there are TWO ways to do this and you need to know which one you're in, bestie. first, the raw syscall life โ and heads up, since Linux 2.1.30 there are symbolic names LINUX_REBOOT_* for the constants AND a fourth argument to the call:
/* Since Linux 2.1.30 there are symbolic names LINUX_REBOOT_*
for the constants and a fourth argument to the call: */
#include <linux/reboot.h> /* Definition of LINUX_REBOOT_* constants */
#include <sys/syscall.h> /* Definition of SYS_* constants */
#include <unistd.h>
int syscall(SYS_reboot, int magic, int magic2, int op, void *arg);
and then the friendly version, which is what you get under glibc and most alternative libc's (including uclibc, dietlibc, musl and a few others) โ some of the constants involved have gotten symbolic names RB_*, and the library call is a 1-argument wrapper around the system call:
/* Under glibc and most alternative libc's (including uclibc, dietlibc,
musl and a few others), some of the constants involved have gotten
symbolic names RB_*, and the library call is a 1-argument
wrapper around the system call: */
#include <sys/reboot.h> /* Definition of RB_* constants */
#include <unistd.h>
int reboot(int op);
one arg vs four args, pick your fighter โจ
๐ธ DESCRIPTION ๐ธ
The reboot() call reboots the system, or enables/disables the reboot keystroke (abbreviated CAD, because the default is Ctrl-Alt-Delete โ and yes it can be changed using loadkeys(1)). so cute, so powerful ๐
here's the gatekeeping part, and she is STRICT: this system call fails (with the error EINVAL) unless magic equals LINUX_REBOOT_MAGIC1 (that is, 0xfee1dead) and magic2 equals LINUX_REBOOT_MAGIC2 (that is, 0x28121969). however โ since Linux 2.1.17 also LINUX_REBOOT_MAGIC2A (that is, 0x05121996) and since Linux 2.1.97 also LINUX_REBOOT_MAGIC2B (that is, 0x16041998) and since Linux 2.5.71 also LINUX_REBOOT_MAGIC2C (that is, 0x20112000) are permitted as values for magic2. (the hexadecimal values of these constants are meaningful. no cap. ๐)
the op argument can have the following values:
LINUX_REBOOT_CMD_CAD_OFFโ (RB_DISABLE_CAD,0). CAD is disabled. This means that the CAD keystroke will cause aSIGINTsignal to be sent toinit(process 1), whereupon this process may decide upon a proper action (maybe: kill all processes, sync, reboot). it's giving "you handle it, i trust you" ๐LINUX_REBOOT_CMD_CAD_ONโ (RB_ENABLE_CAD,0x89abcdef). CAD is enabled. This means that the CAD keystroke will immediately cause the action associated withLINUX_REBOOT_CMD_RESTART. instant, no thoughts head empty ๐LINUX_REBOOT_CMD_HALTโ (RB_HALT_SYSTEM,0xcdef0123; since Linux 1.1.76). The message"System halted."is printed, and the system is halted. Control is given to the ROM monitor, if there is one. If not preceded by async(2), data will be lost. ma'am. please sync. ๐ญLINUX_REBOOT_CMD_KEXECโ (RB_KEXEC,0x45584543, since Linux 2.6.13). Execute a kernel that has been loaded earlier withkexec_load(2). This option is available only if the kernel was configured withCONFIG_KEXEC. very specialist, very main character ๐LINUX_REBOOT_CMD_POWER_OFFโ (RB_POWER_OFF,0x4321fedc; since Linux 2.1.30). The message"Power down."is printed, the system is stopped, and all power is removed from the system, if possible. If not preceded by async(2), data will be lost. again with the sync. sync bestie sync ๐ซถLINUX_REBOOT_CMD_RESTARTโ (RB_AUTOBOOT,0x1234567). The message"Restarting system."is printed, and a default restart is performed immediately. If not preceded by async(2), data will be lost. (do you see a pattern. do you see it.) ๐LINUX_REBOOT_CMD_RESTART2โ (0xa1b2c3d4; since Linux 2.1.30). The message"Restarting system with command '%s'"is printed, and a restart (using the command string given inarg) is performed immediately. If not preceded by async(2), data will be lost. ๐ฅLINUX_REBOOT_CMD_SW_SUSPENDโ (RB_SW_SUSPEND,0xd000fce1; since Linux 2.5.18). The system is suspended (hibernated) to disk. This option is available only if the kernel was configured withCONFIG_HIBERNATION. naptime fr fr ๐ด
Only the superuser may call reboot(). rules are rules ๐
The precise effect of the above actions depends on the architecture. For the i386 architecture, the additional argument does not do anything at present (2.1.122), but the type of reboot can be determined by kernel command-line arguments ("reboot=...") to be either warm or cold, and either hard or through the BIOS. architectural differences, we love an unpredictable queen ๐ฆ
๐ง Behavior inside PID namespaces ๐ง
Since Linux 3.4, if reboot() is called from a PID namespace other than the initial PID namespace with one of the op values listed below, it performs a "reboot" of that namespace: the "init" process of the PID namespace is immediately terminated, with the effects described in pid_namespaces(7). so you can reboot inside your little container bubble. intimate. โจ
The values that can be supplied in op when calling reboot() in this case are as follows:
LINUX_REBOOT_CMD_RESTARTLINUX_REBOOT_CMD_RESTART2
The "init" process is terminated, and wait(2) in the parent process reports that the child was killed with a SIGHUP signal.
LINUX_REBOOT_CMD_POWER_OFFLINUX_REBOOT_CMD_HALT
The "init" process is terminated, and wait(2) in the parent process reports that the child was killed with a SIGINT signal.
For the other op values, reboot() returns -1 and errno is set to EINVAL. wrong lane, rejected, no entry ๐ซ
๐ RETURN VALUE ๐
For the values of op that stop or restart the system, a successful call to reboot() does not return. (she left and she's not coming back ๐) For the other op values, zero is returned on success. In all cases, -1 is returned on failure, and errno is set to indicate the error.
๐ฅ ERRORS ๐ฅ
EFAULTโ Problem with getting user-space data underLINUX_REBOOT_CMD_RESTART2. couldn't read your stuff, sad ๐ฅฒEINVALโ Bad magic numbers orop. wrong vibes detected, vibe check failed ๐EPERMโ The calling process has insufficient privilege to callreboot(); the caller must have theCAP_SYS_BOOTinside its user namespace. no permission bestie, go get your capabilities ๐
โญ STANDARDS โญ
Linux. just Linux. periodt. ๐ธ
๐ฆ SEE ALSO ๐ฆ
systemctl(1), systemd(1), kexec_load(2), sync(2), bootparam(7), capabilities(7), ctrlaltdel(8), halt(8), shutdown(8)
and that's the whole page bestie ๐ this one's from Linux man-pages 6.20, dated 2026-02-08 โ go forth, sync first, and slay responsibly ๐ซถโจ
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: Linux-man-pages-copyleft
- Copyright 1998, Andries E. Brouwer <aeb@cwi.nl>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms