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 a SIGINT signal to be sent to init (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 with LINUX_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 a sync(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 with kexec_load(2). This option is available only if the kernel was configured with CONFIG_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 a sync(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 a sync(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 in arg) is performed immediately. If not preceded by a sync(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 with CONFIG_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_RESTART
  • LINUX_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_OFF
  • LINUX_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 under LINUX_REBOOT_CMD_RESTART2. couldn't read your stuff, sad ๐Ÿฅฒ
  • EINVAL โ€” Bad magic numbers or op. wrong vibes detected, vibe check failed ๐Ÿ’…
  • EPERM โ€” The calling process has insufficient privilege to call reboot(); the caller must have the CAP_SYS_BOOT inside 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
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms