How To Reboot Ubuntu From Command Line

13 min read

Restarting an Ubuntu system via the terminal is a fundamental skill for administrators, developers, and power users managing headless servers or working within a minimal desktop environment. And the command line offers precise control over the reboot process, allowing for immediate restarts, scheduled downtime, forced shutdowns, and even broadcasting custom messages to logged-in users. Mastering these commands ensures you can maintain system uptime, apply kernel updates effectively, and recover from frozen states without physical access to the machine It's one of those things that adds up. Turns out it matters..

The Standard Reboot Command

The most common and straightforward way to restart Ubuntu is using the reboot command. Practically speaking, this utility is a symbolic link to systemctl reboot on modern systemd-based distributions (Ubuntu 16. 04 and later), ensuring a clean shutdown sequence where services are stopped gracefully before the hardware reset initiates Worth keeping that in mind. But it adds up..

To execute a standard restart, open your terminal and type:

reboot

Because this action affects the entire system, you typically require root privileges. If you are not logged in as root, prefix the command with sudo:

sudo reboot

You will be prompted for your user password. Once authenticated, the system begins the shutdown sequence immediately: terminating user processes, unmounting filesystems, and signaling the kernel to restart the hardware. This is the go-to method for routine maintenance, such as applying standard package updates that do not require a kernel swap.

Using Systemd for Explicit Control

Since Ubuntu migrated to systemd, the systemctl command has become the canonical way to manage system states. Using systemctl reboot is functionally identical to the standalone reboot command but offers better integration with the service manager and clearer logging in the systemd journal Easy to understand, harder to ignore..

sudo systemctl reboot

This command triggers the reboot.target unit. One advantage of using systemctl explicitly is the ability to combine it with other flags or to inspect the reboot logic via systemctl status reboot.target if troubleshooting is required. For scripting and automation, systemctl is often preferred because its exit codes and output formatting are strictly defined, making it easier to parse programmatically.

Scheduling a Delayed Restart

In production environments, an immediate reboot can disrupt active users or running batch jobs. Plus, the shutdown command provides solid scheduling capabilities, allowing you to define a specific time or a delay in minutes. This gives users a warning window to save their work Nothing fancy..

The official docs gloss over this. That's a mistake.

To reboot in 10 minutes, use the +m syntax:

sudo shutdown -r +10

To reboot at a specific time (24-hour format), use hh:mm:

sudo shutdown -r 23:30

The -r flag stands for reboot. Worth adding: without it, shutdown defaults to halting (powering off) the system. When a scheduled reboot is initiated, Ubuntu broadcasts a wall message to all logged-in terminals, notifying users of the impending restart.

sudo shutdown -c

This cancellation also broadcasts a message informing users that the scheduled restart has been aborted And that's really what it comes down to..

Broadcasting Custom Messages

When managing multi-user servers, communication is key. Also, the shutdown command allows you to append a custom message that will be sent to all active terminals (pts and tty sessions). This is invaluable for informing colleagues why the server is going down Which is the point..

sudo shutdown -r +5 "Scheduled maintenance: Applying critical security patches. Server will be back shortly."

The message appears in the terminal of every logged-in user, providing context that a generic "system going down" notice lacks. This practice reduces support tickets and confusion during planned maintenance windows.

Forcing an Immediate Reboot

There are scenarios where the standard graceful shutdown hangs—perhaps a filesystem is stuck, a network mount is unresponsive, or a process refuses to terminate (ignoring SIGTERM). In these cases, a forced reboot is necessary. This bypasses the normal service shutdown sequence and instructs the kernel to reset immediately.

Use the -f (force) flag with reboot or systemctl:

sudo reboot -f

Or:

sudo systemctl --force reboot

Warning: Using --force once skips the service shutdown but still attempts to unmount filesystems. Using it twice (sudo systemctl --force --force reboot or sudo reboot -f -f) triggers an immediate kernel reboot via the reboot() syscall, completely skipping userspace shutdown logic. This carries a high risk of data corruption or filesystem inconsistency (requiring fsck on next boot). Reserve the double-force method strictly for emergencies where the system is otherwise unresponsive and a hardware reset button is not accessible.

Rebooting Into Firmware (UEFI/BIOS)

On modern hardware utilizing UEFI, you can instruct the system to reboot directly into the firmware setup utility (BIOS/UEFI menu) rather than the bootloader. This is extremely useful for headless servers or laptops where fast boot settings make catching the F2/Del key difficult Simple, but easy to overlook..

sudo systemctl reboot --firmware-setup

This command sets a specific EFI variable (OsIndications) telling the firmware to enter the setup screen on the next boot. Note that this requires kernel support (CONFIG_EFI_VARS) and a UEFI-based system; it will not work on legacy BIOS (CSM) boot modes.

Managing Reboots on Remote Servers (SSH)

Rebooting a remote server via SSH requires caution. Once the command executes, your session will terminate immediately. If the server fails to come back online (due to a kernel panic, network misconfiguration, or hung filesystem check), you lose access entirely Most people skip this — try not to. And it works..

Best practices for remote reboots:

  1. Verify connectivity redundancy: Ensure you have an out-of-band management solution (IPMI, iDRAC, iLO, or cloud provider console access) before issuing the command.
  2. Check for pending updates: Run sudo apt update && sudo apt list --upgradable to ensure a kernel update isn't pending that might require a specific boot parameter.
  3. Use a terminal multiplexer: Run the reboot command inside a screen or tmux session. If the SSH connection drops before the command executes (network blip), the command continues to run on the server.
  4. Schedule instead of instant: Use sudo shutdown -r +1 "Remote maintenance reboot" to give yourself a 60-second buffer to disconnect cleanly and verify the command was accepted.

Troubleshooting Common Reboot Issues

The "System is rebooting" Message Persists

If you run reboot and see the message System is rebooting but the machine hangs, the kernel may be waiting for a device to release a lock. Try the Magic SysRq key combination if you have console access: Alt + SysRq + R, E, I, S, U, B (Reboot Even If System Utterly Broken). Via command line (if kernel supports it):

echo b | sudo tee /proc/sysrq-trigger

This triggers an immediate, ungraceful reboot similar to reboot -f -f And it works..

Failed to Start Reboot Target

If systemctl reboot fails with a dependency error, a service may be stuck in a "stopping" state. Check the journal:

journalctl -xe -u 

You may need to mask or force-stop the offending service before retrying the reboot.

Kernel Panic on Boot

If the server reboots but fails to start (kernel panic), it often indicates a mismatch between the kernel version and initramfs, or a missing driver for the root filesystem. This requires booting from a Live USB/ISO to chroot into the installation and regenerate

Regenerating the initramfs is only the first half of the remedy; the bootloader must also be refreshed so that the new kernel image is correctly referenced. From the live environment, mount the installed system’s root partition (e.g., /dev/sda2 → /mnt) and bind‑mount the necessary pseudo‑filesystems (/dev, /proc, /sys, /run).

This changes depending on context. Keep that in mind.

mount /dev/sda2 /mnt
mount --bind /dev  /mnt/dev
mount --bind /proc /mnt/proc
mount --bind /sys  /mnt/sys
mount --bind /run  /mnt/run
chroot /mnt

Inside the chroot, rebuild the initial RAM filesystem for every installed kernel version:

update-initramfs -u -k all

If the system uses GRUB as its bootloader, reinstall it and regenerate the configuration:

grub-install /dev/sda
update-grub

Should the bootloader be systemd‑boot or another EFI‑based manager, the equivalent steps are bootctl update or efibootmgr adjustments, respectively. After completing these actions, exit the chroot, unmount all bind mounts, and power off the machine. A clean reboot should now bring the system up without the previous panic Simple, but easy to overlook..

Beyond immediate fixes, there are several preventive measures to keep remote reboots reliable:

  1. Automated health checks – Deploy a monitoring agent that watches key services, disk space, and kernel logs. When a threshold is crossed, the agent can trigger a graceful reboot via systemctl reboot or schedule it through a systemd timer, eliminating the need for manual intervention during peak loads.

  2. Version‑controlled configuration – Keep /etc/fstab, /etc/default/grub, and any custom initramfs hooks under version control. This makes it easy to roll back a change that introduced a driver mismatch or broke a mount point.

  3. Redundant management paths – In addition to the out‑of‑band console, enable serial console access or use the provider’s rescue API. These channels remain available even when the network stack collapses, allowing you to issue a forced reboot (reboot -f) if the normal path fails Simple, but easy to overlook..

  4. Testing in isolation – Before applying a kernel upgrade on production, spin up a disposable VM that mirrors the target architecture. Perform the upgrade, run the full reboot cycle, and verify that the system boots cleanly. This practice catches regressions that might otherwise surface only on the live host Not complicated — just consistent..

  5. Graceful shutdown scripts – For services that hold long‑running transactions (databases, virtual machines), embed a pre‑shutdown hook that drains connections and flushes buffers. This reduces the chance of a hung process preventing the kernel from completing the reboot sequence.

When a reboot is unavoidable, combine the safeguards above with a clear communication plan. Notify all stakeholders, acquire a maintenance window, and verify that the out‑of‑band console is reachable. Issue the command from within a tmux session or a screen window so that loss of the SSH link does not abort the operation. Finally, monitor the post‑reboot metrics for at least a few minutes to confirm that critical services have resumed and that no unexpected errors appear in the system journal.

Boiling it down, a reliable reboot strategy hinges on three pillars: preparation (redundant

preparation (redundant access options, continuous observation, and repeatable procedures) Most people skip this — try not to..

First, maintain several independent ways to reach the host even when the primary network path fails. Because of that, in addition to the out‑of‑band console, provision a serial console, the provider’s rescue API, or a secondary management IP that can be reached through a different VLAN. These channels let you issue a forced reboot (reboot -f) or perform recovery steps without relying on the standard SSH session Easy to understand, harder to ignore..

Second, embed continuous observation into

Continuing from “Second, embed continuous observation into…”

Continuous observation means installing light‑weight watchdog agents across every tier of the stack so that anomalies are spotted long before they become show‑stoppers. On Linux hosts this typically involves:

  1. System‑level monitors – Tools such as monit, collectl, or the newer systemd-cgtop can poll CPU load, memory pressure, disk I/O, and network latency every few seconds.
  2. Kernel‑side telemetry – Enabling kernel.full debugging or feeding /proc/sys/kernel/random/vdev statistics gives insight into interrupt storms and firmware mismatches.
  3. Container‑runtime hooks – If workloads run in containers, sidecar probes (e.g., kubelet’s liveness probe) report health back to the orchestrator.
  4. Resource limits & OOM tracking – Setting memory.maxsize in /etc/sysctl.conf and watching vm_count flags prevents OOM kills from silently starving critical services.

All of these feeds are forwarded to a central dashboard (Prometheus + Grafana is common) where thresholds—such as >80 % CPU sustained for two minutes or >90 % disk usage for five consecutive scans—trigger alerts. Alerts are routed to on‑call engineers via Slack, email, or PagerDuty, giving enough lead time to apply pre‑defined mitigation actions (restarting services, draining connections, or queuing a forced reboot).

Not the most exciting part, but easily the most useful.

Because configuration files—including those embedded in initramfs—are version‑controlled, any change made to the monitoring stack can be rolled back instantly if a spurious spike indicates a misconfiguration rather than a real incident. Also worth noting, periodic “heartbeat” jobs can verify that the out‑of‑band console remains reachable after a network partition; loss of serial or rescue‑API connectivity would immediately flag the redundancy

Beyond the initial detection phase, the next critical step is validation. A reboot plan is only as good as the evidence that it works when the situation actually arises. Teams should therefore schedule regular “dry‑run” drills that simulate the exact conditions that trigger a forced reboot—network isolation, loss of primary console, and high‑load spikes That alone is useful..

  1. Isolate the host – Disconnect the primary NIC, or block the management VLAN, to force the system onto the out‑of‑band channel.
  2. Verify reachability – Run a quick ping or ssh (if available) from the secondary console to confirm that the host is still audible.
  3. Execute the reboot command – Issue reboot -f or the provider‑specific “hard reset” API call.
  4. Observe the boot cycle – Use the serial console or rescue API to watch the kernel boot messages, verify that essential services start in the correct order, and confirm that the health‑checks re‑initialize successfully.
  5. Post‑reboot validation – Run a suite of automated tests (e.g., service‑specific curl checks, database connectivity probes, or synthetic transaction metrics) to ensure the workload is truly functional before traffic is re‑routed.

If any step fails, the drill logs the exact point of breakdown and updates the run‑book accordingly. Because the steps are codified as Ansible playbooks or Terraform modules, the same sequence can be triggered manually or via an automated webhook when an alert fires. This eliminates human latency and guarantees repeatability That's the whole idea..

A closely related practice is configuration drift control. The reboot procedure often depends on specific kernel parameters, filesystem mount options, or service‑level settings that must be consistent across reboots. By storing these settings in a version‑controlled repository (e.g., a GitOps manifest) and applying them through immutable infrastructure pipelines, teams can guarantee that a reboot will not inadvertently alter the environment in a way that re‑introduces the original failure mode But it adds up..

Another layer of safety is rollback orchestration. Practically speaking, the rescue API can mount the root filesystem read‑only, chroot into the existing root image, and run package‑manager commands to revert recent updates or re‑apply known‑good kernel images. Should a forced reboot leave the host in an unrecoverable state—perhaps due to a corrupted bootloader or a mismatched firmware version—having a secondary “rescue” path is essential. Documenting these commands in a separate “recovery” playbook ensures that engineers can act without needing to consult multiple sources under pressure The details matter here..

Not obvious, but once you see it — you'll see it everywhere.

Finally, metrics of the reboot itself should be captured and analyzed. Because of that, after each successful reboot, record the duration of the outage, the time to re‑establish primary network connectivity, and any post‑reboot anomalies detected by the watchdog agents. Over time, this data reveals patterns—such as longer boot times after a particular firmware version or recurring network flaps when the primary NIC is re‑enabled—allowing proactive adjustments before a real incident occurs.


Conclusion

A dependable reboot strategy is not a single command but a holistic system built on three inter‑locking pillars:

  1. Preparation – Multiple, independent access vectors (out‑of‑band console, serial console, rescue API, secondary management IP) make sure a host can be reached even when the primary network path is lost.
  2. Continuous observation – Lightweight, tier‑spanning watchdog agents feed real‑time telemetry to a central dashboard, enabling early detection of the conditions that justify a forced reboot and providing the lead time needed for automated mitigation.
  3. Validation & automation – Structured dry‑run drills, version‑controlled configuration, automated playbooks, and reliable rollback paths guarantee that the reboot can be executed reliably, measured accurately, and reverted safely if necessary.

When these pillars are deliberately engineered, the organization transforms a potentially catastrophic failure into a controlled, repeatable operation—minimizing downtime, preserving data integrity, and maintaining confidence in the overall resilience of the infrastructure.

Out Now

Recently Written

Related Corners

Round It Out With These

Thank you for reading about How To Reboot Ubuntu From Command Line. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home