Website Vidya
Linux & ServersStep-by-Step Guide

reboot Command in Linux: Restart with systemctl and shutdown

Learn reboot command in linux with syntax, essential flags, practical terminal examples, real-world sysadmin workflows, security tips, and troubleshooting.

RR
Rajesh RayLead Systems Educator
Published:
11 min read
PDF Cheat Sheet
reboot Command in Linux: Restart with systemctl and shutdown
AI Executive SummaryWebsiteVidya AI

11 min read

Learn reboot command in linux with syntax, essential flags, practical terminal examples, real-world sysadmin workflows, security tips, and troubleshooting.

Key Highlights
  • What reboot Does and When to Use It
  • Availability and Installation Across Linux Distributions
  • Command Syntax, Arguments, and Exit Status Codes
Grounded in full engineering runbookWebsiteVidya AI Engine

Interactive Builder for this Guide

Build your custom systemd syntax (reboot Command in Linux: Restart with systemctl and shutdown)

Generated Config Output
[Unit]
Description=Core API Node Service
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
User=www-data
WorkingDirectory=/opt/myapp
EnvironmentFile=/opt/myapp/.env
ExecStart=/usr/bin/node dist/server.js
Restart=on-failure
RestartSec=5
NoNewPrivileges=true

[Install]
WantedBy=multi-user.target
Systemd service unit running "/usr/bin/node dist/server.js" under user "www-data" with Restart=on-failure.
Flag-by-Flag Breakdown
After=network-online.targetWaits until host networking is online before launching
User=www-dataRuns process with least privilege instead of root
Restart=on-failureAutomatically recovers process after crashes (delay 5s)
NoNewPrivileges=trueSecurity hardening preventing child privilege escalation

Using the reboot command in linux is one of the most critical administrative operations performed during kernel upgrades, glibc security patching, hardware reconfiguration, and hypervisor maintenance. While typing reboot at a root shell appears straightforward, restarting a multi-user production server involves a carefully orchestrated teardown sequence so active database transactions, open network sockets, and dirty page-cache buffers are not corrupted.

Across modern enterprise distributions—including Ubuntu, Debian, Red Hat Enterprise Linux (RHEL), Rocky Linux, AlmaLinux, Fedora, and Arch Linux—the legacy /sbin/reboot, /sbin/shutdown, and /sbin/halt binaries are symbolic links pointing directly to /bin/systemctl. Whether you invoke sudo reboot, sudo systemctl reboot, or sudo shutdown -r now, the underlying service manager executes the same target transition toward reboot.target.

Understanding the nuances between immediate restarts, scheduled maintenance windows with wall notifications, firmware setup transitions, and emergency kernel resets ensures you can reboot remote bare-metal servers and cloud virtual machines cleanly without triggering unintended downtime or filesystem recovery delays.

Advertisement
reboot Command in Linux: Restart with systemctl and shutdown — syntax, flags, and practical terminal workflow diagram
reboot Command in Linux: Restart with systemctl and shutdown — command syntax, key options, and production workflow reference.

What reboot Does and When to Use It

When you execute a standard reboot on a systemd-based Linux host, the command communicates with PID 1 over the private D-Bus socket or /run/systemd/private to isolate and activate reboot.target. First, systemd checks for active inhibitor locks registered via systemd-inhibit (such as unattended package upgrades or active backup jobs). Next, it stops all running service units in reverse dependency order, sending SIGTERM to each control group (cgroup) and waiting up to TimeoutStopSec (typically 90 seconds) before issuing SIGKILL to stubborn processes.

Once user-space daemons have exited, systemd transitions to shutdown.target and invokes systemd-shutdown as PID 1. This binary unmounts all non-root filesystems, remounts the root filesystem as read-only, detaches loopback devices, disassembles software RAID and LVM/dm-crypt volumes, calls the sync(2) system call to flush kernel page caches to non-volatile storage, and finally invokes the reboot(2) system call with the LINUX_REBOOT_CMD_RESTART magic flag to trigger a hardware or hypervisor reset.

Under the hood, reboot gathers runtime telemetry or dispatches control signals by reading virtual filesystems mounted at /proc and /sys, or by communicating with PID 1 (systemd) over D-Bus. Using flags such as -p, -f, -w, -d turns raw process and service tables into actionable diagnostics during incident response.

Availability and Installation Across Linux Distributions

The reboot utility is packaged in systemd-sysv across mainstream Linux distributions. It is pre-installed on standard Ubuntu, Debian, RHEL, Rocky Linux, AlmaLinux, Fedora, and Arch Linux systems, while minimal container images may require manual installation:

Advertisement

Before running administrative tasks or automation scripts, verify whether reboot is installed and inspect which binary path and version your shell resolves:

type -a reboot
reboot --version 2>/dev/null || man -f reboot

# Illustrative output (reviewed against documentation)
reboot is /usr/bin/reboot
reboot (systemd-sysv)
# Debian / Ubuntu
sudo apt-get update && sudo apt-get install -y systemd-sysv

# RHEL / Rocky / AlmaLinux / Fedora
sudo dnf install -y systemd

# Arch Linux
sudo pacman -S --noconfirm systemd-sysvcompat

# Alpine Linux
sudo apk add --no-cache openrc

Command Syntax, Arguments, and Exit Status Codes

reboot [OPTIONS] | systemctl reboot [OPTIONS] | shutdown -r [TIME] [MESSAGE]

Linux provides three primary command syntaxes for restarting a system: reboot [OPTIONS] for concise compatibility, systemctl reboot [OPTIONS] for explicit systemd control and inhibitor inspection, and shutdown -r [TIME] [WALL_MESSAGE] when you need to schedule a restart in the future or broadcast a warning to logged-in SSH sessions.

In the shutdown -r syntax, the TIME argument accepts three formats: the literal keyword now (an alias for +0), a relative offset in minutes written as +m (for example, +15 for fifteen minutes from now), or an absolute 24-hour clock timestamp written as hh:mm (for example, 02:30). Any trailing words after the time specification are concatenated and broadcast to all active pseudo-terminals (pts/*) and virtual consoles (tty*) while creating the /run/nologin lock file five minutes before the restart.

  • 0 — Successful execution with no runtime or permission errors.
  • 1 — Operational failure, unmatched condition, or permission restriction.
  • 2 — Invalid command-line option or malformed syntax.

Important Options and Flags Reference

Option / FlagLong Form / ArgumentTechnical Behavior and Purpose
-p--poweroffPowers off the machine rather than restarting it when invoked via the halt or reboot compatibility binary.
-f--forceForces an immediate reboot by bypassing the clean systemd service stop sequence and invoking the reboot(2) system call directly.
-w--wtmp-onlyWrites a simulated shutdown and reboot entry to /var/log/wtmp and /var/run/utmp without actually restarting the machine.
-d--no-wtmpSuppresses writing the reboot record to the /var/log/wtmp audit database during system restart.
--no-wall--no-wallPrevents systemd-logind and shutdown from broadcasting a terminal wall notification to logged-in users before restarting.
-r--reboot (shutdown)Instructs the shutdown utility to reboot the host after bringing down services and unmounting filesystems.
-c--cancel (shutdown)Cancels a pending scheduled shutdown or reboot timer and removes the /run/nologin login restriction file.
--firmware-setup--firmware-setup (systemctl)Instructs the system firmware (UEFI) to boot directly into the BIOS/UEFI configuration menu on the next restart.

In daily administration, the most critical distinction is between a normal graceful restart and the -f (--force) flag. Passing reboot -f once tells PID 1 to skip stopping unit files and jump straight to unmounting filesystems; passing reboot -ff twice bypasses PID 1 completely and calls the kernel reboot(2) syscall immediately—an action equivalent to pressing the physical reset button that should only be used when the init system itself is deadlocked.

Advertisement

When automating reboots in configuration management tools like Ansible or cloud-init, combining systemctl reboot --no-wall or shutdown -r +1 gives remote SSH orchestration wrappers enough time to receive a clean exit code (0) and close the TCP connection gracefully before the remote network stack tears down.

When combining short flags on the command line, POSIX and GNU utilities allow clustering boolean flags behind a single hyphen, provided any option taking an argument appears last. In automated shell scripts, using long-form GNU options where portable makes self-documenting code that is easier to audit during peer review.

Practical Basic and Advanced Usage Examples

1. Restart the System Immediately with systemctl or reboot

On any modern systemd Linux server, run systemctl reboot or the classic reboot command with sudo privileges to initiate an immediate, graceful system restart.

sudo systemctl reboot
# Or using the classic compatibility command:
sudo reboot

# Illustrative output (reviewed against documentation)
Connection to 192.0.2.45 closed by remote host.
Connection to 192.0.2.45 closed.

Both commands notify systemd-logind, stop all running services in reverse dependency order, flush dirty filesystem pages to disk, and reset the machine.

2. Schedule a Delayed Reboot with a Broadcast Message

When multiple engineers or application users are logged into a shared server, schedule the restart 10 minutes ahead using shutdown -r so active sessions receive a warning.

sudo shutdown -r +10 "Kernel security update (CVE-2026-XXXX) — save open work"

# Illustrative output (reviewed against documentation)
Reboot scheduled for Thu 2026-10-22 19:15:00 UTC, use 'shutdown -c' to cancel.

Systemd creates a scheduled timer, broadcasts the custom message across all open PTY terminals periodically, and blocks new non-root SSH logins via /run/nologin five minutes prior to execution.

3. Schedule a Reboot for a Specific Maintenance Window Time

Use 24-hour clock notation (HH:MM) with shutdown -r to queue an unattended restart for an off-peak maintenance window.

sudo shutdown -r 03:00 "Scheduled nightly maintenance window reboot"

# Illustrative output (reviewed against documentation)
Reboot scheduled for Fri 2026-10-23 03:00:00 UTC, use 'shutdown -c' to cancel.

The timer remains active in systemd-logind until 03:00 local server time. You can inspect the pending schedule at any time by reading /run/systemd/shutdown/scheduled.

4. Cancel a Pending Scheduled Reboot

If a deployment window changes or an urgent task is still running, abort a queued shutdown or reboot timer with shutdown -c.

sudo shutdown -c "Maintenance window postponed until tomorrow"
cat /run/systemd/shutdown/scheduled 2>/dev/null || echo "No reboot currently scheduled"

# Illustrative output (reviewed against documentation)
No reboot currently scheduled

The -c flag clears the active shutdown timer in systemd-logind, deletes /run/nologin so standard SSH users can log in again, and broadcasts the cancellation notice.

5. Record a Simulated Reboot Entry in wtmp Without Restarting

Use the -w (--wtmp-only) option to test log rotation or audit monitoring scripts that parse /var/log/wtmp without actually taking the host offline.

sudo reboot -w
last -x -n 2 reboot

# Illustrative output (reviewed against documentation)
reboot   system boot  6.8.0-45-generic Thu Oct 22 19:05   still running
wtmp begins Thu Oct 01 00:00:02 2026

The -w flag writes a record to the wtmp accounting file for testing compliance pipelines while leaving all running services and uptime completely untouched.

6. Reboot Directly into UEFI Firmware Setup or Specific Boot Loader Entry

On UEFI-enabled hardware or virtual machines, instruct systemd to set the EFI OsIndications variable so the machine boots into the firmware interface on restart.

sudo systemctl reboot --firmware-setup

# Illustrative output (reviewed against documentation)
Rebooting into firmware setup interface...

If supported by the motherboard or hypervisor OVMF firmware, the system automatically enters the UEFI BIOS setup screen on the next boot cycle.

Real-World Workflows, Pipelines, and Shell Automation

Pre-Reboot Production Health Check and Inhibitor Audit

Before restarting a production node after patching, verify whether a kernel reboot is actually required, check for active systemd inhibitor locks, and validate configuration syntax for critical services.

#!/usr/bin/env bash
set -euo pipefail

echo "=== 1. Checking if kernel or core library reboot is required ==="
if [ -f /var/run/reboot-required ]; then
  cat /var/run/reboot-required
  cat /var/run/reboot-required.pkgs 2>/dev/null || true
elif command -v needs-restarting >/dev/null 2>&1; then
  needs-restarting -r || true
fi

echo "=== 2. Auditing active systemd inhibitor locks ==="
systemd-inhibit --list

echo "=== 3. Checking active user sessions and fstab mount integrity ==="
who
sudo findmnt --verify

echo "=== 4. Scheduling graceful reboot in 2 minutes ==="
sudo shutdown -r +2 "Automated post-patch reboot after pre-flight verification"

# Illustrative output (reviewed against documentation)
=== 1. Checking if kernel or core library reboot is required ===
*** System restart required ***
linux-image-6.8.0-45-generic
=== 2. Auditing active systemd inhibitor locks ===
WHO            UID USER PID  COMM           WHAT  WHY                      MODE
unattended-upgr 0   root 4112 unattended-upg shutdown Installing upgrades   delay
=== 3. Checking active user sessions and fstab mount integrity ===
admin    pts/0        2026-10-22 18:40 (198.51.100.12)
Success, no errors or warnings detected
=== 4. Scheduling graceful reboot in 2 minutes ===
Reboot scheduled for Thu 2026-10-22 19:08:00 UTC, use 'shutdown -c' to cancel.

Running findmnt --verify before rebooting is one of the highest-leverage sysadmin habits: it catches typos in /etc/fstab before they drop your remote server into an unreachable emergency-mode shell during boot.

Fast Kernel Reboot Using kexec to Bypass Hardware POST

On bare-metal enterprise servers where BIOS/UEFI memory training and hardware POST take several minutes, load the new kernel directly into memory with kexec and trigger a fast systemctl kexec restart.

# Load the newly installed kernel and initramfs into memory
NEW_KERNEL=$(ls -1 /boot/vmlinuz-* | sort -V | tail -n 1)
NEW_INITRD="/boot/initrd.img-${NEW_KERNEL#/boot/vmlinuz-}"
CMDLINE=$(cat /proc/cmdline)

sudo kexec -l "$NEW_KERNEL" --initrd="$NEW_INITRD" --command-line="$CMDLINE"
sudo systemctl kexec

# Illustrative output (reviewed against documentation)
Stopping services and executing kexec jump to /boot/vmlinuz-6.8.0-45-generic...

systemctl kexec performs the full, safe systemd service shutdown and filesystem unmount sequence, but instead of triggering a hardware reset, it jumps directly into the preloaded kernel image—cutting bare-metal reboot downtime from minutes to seconds.

Pipelines, Redirection, Quoting, and Shell Expansion

When embedding reboot inside shell pipelines (|), conditional chains (&& and ||), or command substitutions ($(...)), the calling shell performs tilde expansion, variable interpolation, and globbing before invoking the binary. Always wrap paths, patterns, and variables in quotes so whitespace and wildcard characters (*, ?) are not expanded prematurely, and use set -euo pipefail in unattended scripts.

Permissions, Security Implications, and Safe Execution

Restarting a Linux host is a privileged operation governed by PolicyKit (polkit) and root credentials. When an unprivileged user runs systemctl reboot from a local graphical seat, Polkit may permit the restart only if no other users are logged in; over remote SSH sessions, Polkit denies unprivileged reboot requests and requires explicit sudo elevation.

Every reboot and shutdown event is logged both to the systemd journal and to the binary accounting file /var/log/wtmp. Security teams can audit historical restarts and distinguish between graceful administrative reboots and unexpected kernel panics or power losses by running last -x reboot shutdown and journalctl --list-boots.

GNU/Linux, BSD, and BusyBox Implementation Differences

On systemd distributions (Ubuntu, Debian, RHEL, Fedora, Arch), reboot, shutdown -r, and systemctl reboot all route through PID 1. On Alpine Linux (which uses OpenRC and BusyBox init) and Void Linux (runit), systemctl does not exist; use sudo reboot or sudo shutdown -r now instead.

On FreeBSD and macOS, the shutdown -r now command is preferred over raw reboot because BSD's shutdown executes /etc/rc.shutdown hooks cleanly, whereas BSD reboot only sends SIGTERM to processes without running full RC stop scripts.

Troubleshooting Common Errors and Diagnostics

System hangs on 'A stop job is running for...' during reboot

Root Cause: A service unit (such as a hung network mount, database, or container runtime) is ignoring SIGTERM and delaying the transition to reboot.target until TimeoutStopSec expires.

Resolution: Inspect which unit is blocking shutdown or lower DefaultTimeoutStopSec in /etc/systemd/system.conf, and unmount stale NFS/CIFS shares lazily before restarting.

sudo systemctl list-jobs
sudo umount -l -t nfs,nfs4,cifs -a 2>/dev/null || true
sudo systemctl reboot

Operation inhibited by 'unattended-upgrades' or another active process

Root Cause: An active process holds a systemd block or delay inhibitor lock to prevent package database corruption during a restart.

Resolution: List active locks with systemd-inhibit --list and wait for the package manager to finish before forcing the reboot.

systemd-inhibit --list
ps -ef | grep -E 'apt|dpkg|dnf'

Server fails to come back online on SSH after reboot

Root Cause: An invalid entry in /etc/fstab without the nofail option caused systemd to drop into Emergency Mode on the local console before sshd could start.

Resolution: Always run sudo findmnt --verify and sudo sshd -t prior to issuing a reboot command on a remote server.

sudo findmnt --verify
sudo sshd -t

Authoritative References and Official Documentation

Frequently Asked Questions

Quick answers to common questions and configurations

4 FAQs
On modern systemd-based Linux distributions, there is no difference in how the system stops services or unmounts filesystems: /sbin/reboot and /sbin/shutdown are symlinks to systemctl. The main practical difference is that shutdown -r accepts a time schedule (+10 or 02:00) and a custom broadcast message.
Run sudo shutdown -c from any root-privileged terminal before the timer reaches zero. You can optionally append a message such as sudo shutdown -c 'Reboot cancelled' to notify logged-in users.
Run uptime -s to view the exact boot timestamp, who -b to see the last system boot time, or last reboot to inspect the historical log of recent system restarts stored in /var/log/wtmp.
Use reboot -f only as a last resort when a normal reboot hangs indefinitely and you cannot stop the offending process. Because -f skips stopping systemd services cleanly, databases and stateful applications may suffer ungraceful termination.
RR
Written byVerified Author

Rajesh Ray

I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.

SPAM-FREE MODERATED DISCOURSE

Join the Conversation & Perspective

Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.

AT
MP
JV
+2

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Featured Infrastructure PartnerUp to 75% OFF + 3 Months Free

Supercharge Your Linux & Cloud Workloads with Hostinger

Deploy high-speed NVMe KVM VPS, Docker containers, and LiteSpeed-accelerated WordPress servers in under 60 seconds with full root access, dedicated IPv4, and 24/7 technical support.

Pure NVMe SSD StorageFull Root Access & SSHFree Domain & Unlimited SSL99.9% Uptime SLA
Plans from$2.99/mo
Claim Hostinger DealAffiliate link • Special discount applied at checkout