How to Restart Ubuntu from the Terminal?
This article provides a quick overview of the commands used to reboot an Ubuntu system directly from the command line. You will learn the standard, safest commands for immediate restarts, how to schedule a reboot for a later time, and how to safely force a restart if your system becomes unresponsive.
The Standard Restart Command
The most common and safest way to restart an Ubuntu system from the
terminal is by using the shutdown command with the
--reboot flag (or -r). Because restarting
affects system-wide operations, you must precede the command with
sudo to grant administrative privileges.
sudo shutdown -r nowAlternatively, you can use the shorter, dedicated reboot
command, which achieves the exact same result:
sudo rebootBoth of these commands signal the operating system to gracefully close all running applications, save ongoing processes, and safely cycle the power.
Scheduling a Delayed Restart
If you are managing a server or working on a shared system, you might
want to postpone the restart to give other users time to save their
work. The shutdown command allows you to specify a time
delay in minutes or set a specific 24-hour timestamp.
- To restart in 10 minutes:
sudo shutdown -r +10 "System restarting for updates in 10 minutes!"- To restart at a specific time (e.g., 2:30 AM):
sudo shutdown -r 02:30The optional string message in quotation marks will be broadcasted to all active terminal sessions on the machine. If you need to cancel a scheduled reboot before it happens, simply run:
sudo shutdown -cAlternative and Emergency Restart Methods
In some scenarios, such as headless server management or system freezes, you might need alternative approaches to initiate a reboot.
Using systemd
Modern Ubuntu releases utilize systemd as their init
system. You can talk directly to the system manager to trigger a
restart:
sudo systemctl rebootThe Emergency Magic SysRq Method
If your Ubuntu desktop or server completely freezes and traditional terminal commands do not respond, you can trigger a low-level reboot using the Linux kernel’s Magic SysRq key combination. This safely flushes data to the disks and reboots without corrupting the file system.
While holding down the Alt and SysRq (often the Print Screen) keys, slowly type the following sequence of letters, pausing for a second between each:
R - E - I - S - U - B
This forces the system to regain control of the keyboard, terminate running processes, sync your hard drives, and safely initiate a hardware reset.