How to Restart Ubuntu From Terminal

Restarting Ubuntu is a common task that we often perform after updating the system, troubleshooting any problems, routine maintenance, etc. Doing this ensures our system runs smoothly. In addition to this, rebooting the system regularly enhances the system’s health and prevents the issues that arise from continuous uptime. Rebooting Ubuntu from GUI is quite easy, but what if we are working on a CLI-based Ubuntu server? Well! In that case, we can restart Ubuntu using various commands.

Content Overview

In this write-up, we’ll discuss how to restart Ubuntu from terminal using:

  1. The reboot Command
  2. The shutdown Command
  3. systemctl
  4. The init Command
  5. The telinit Command
  6. The REISUB Sequence 
  7. The Magic SysRq key

Let’s begin with the reboot command.

How to Restart Ubuntu From Terminal Using the reboot Command

The reboot command is the most convenient and safe way of restarting Ubuntu from the terminal. It ensures minimal data loss and maintains the system integrity while restarting the system. 

When we execute this command, it sends a reboot signal to the system, as a result, the system terminates all the running processes and applications, saves the unsaved data, and then reboots the system. 

To use this, simply type one of the below-given commands in the terminal, and hit the “Enter” button:

sudo reboot           #reboots Ubuntu after the delay of 1 minute
sudo reboot now       #restarts Ubuntu immediately
sudo reboot -f        #reboots Ubuntu forcefully

Note: If you restart Ubuntu forcefully, the unsaved data might be lost. So, use this option carefully. 

How to Restart Ubuntu From Terminal Using the shutdown Command

The shutdown command (as the name itself suggests) is used to shutdown/poweroff a system. However, we can execute this command with the “-r” or “-reboot” option to restart Ubuntu. One core benefit of using this command is we can schedule the reboot. 

Here is a simple syntax to execute this command from the Ubuntu terminal:

sudo shutdown -r             #restarts Ubuntu immediately
sudo shutdown -r +Minutes    #reboots Ubuntu after the specified "Minutes".

In the following example, we schedule an Ubuntu reboot after 6 minutes from now:

shutdown -r +6
Image

Note: We can cancel a scheduled reboot(if needed) at any time using the “shutdown -c” command.

How to Reboot Ubuntu From Terminal Using systemctl

Most modern Linux distributions like Ubuntu, Fedora, Debian, etc., use systemd to manage startup processes, handle system states, etc. Therefore we can use a systemd-specific command to reboot Ubuntu. 

For instance, we can execute the “systemctl reboot” command from the terminal to restart Ubuntu. This command uses systemd control utility to initiate a system reboot. This command gracefully terminates all processes, running services, etc., and then initiates a safe and more consistent reboot process. 

Use the following syntax to execute this command from the Ubuntu terminal: 

sudo systemctl reboot

How to Restart Ubuntu via Terminal Using the init Command

The init command is a classical method used with the runlevel “6” to reboot a system. This method was specifically used in the older versions (SysVinit) of the Ubuntu and other Linux distributions to reboot a system. 

This command still works on different Linux distributions, including Ubuntu. However, the latest Ubuntu versions are systemd-specific, so the “systemctl reboot” is commonly used to restart a system. 

To execute the init command, use the following syntax:

sudo init 6

Note: I execute this command on Ubuntu 24.04 (i.e., the latest Ubuntu version at the time of writing this post) and it works.

How to Restart Ubuntu via Terminal Using the telinit Command

The telinit command is similar to the init command. When we execute this command with runlevel 6, it terminates the running processes and reboots the system. Here’s a simple syntax to execute telinit from the Ubuntu terminal:

sudo telinit 6

How to Restart Ubuntu Terminal Using the REISUB Sequence 

The REISUB sequence is a safe and convenient way of rebooting a system. This method is used in emergency scenarios, i.e., when a system becomes unresponsive. 

It works in a sequence, i.e., first, it switches the keyboard from raw keyboard mode to XLATE mode, terminates and kills all the processes except init, syncs all mounted filesystems, remounts filesystems in read-only mode, and in the end, it restarts the system. 

To use this sequence, open the Ubuntu terminal, press and hold the “alt + prtsc” keys, and type “r”, “e”, “i”, “s”, “u”, and “b” from your keyboard:

ALT + PRTSC + REISUB

How to Restart Ubuntu via Terminal Using the Magic SysRq key

If for some reason Ubuntu becomes completely unresponsive, then you can use this method to reboot your system. This method is a direct invocation of the REISUB sequence from the terminal. It forces an immediate reboot, however this method is unsafe and might cause data loss. 

Run the below-mentioned command from your terminal to restart your system via “sysrq”:

echo b | sudo tee /proc/sysrq-trigger          #b stands for "reboot"

How to Remotely Reboot the Ubuntu Server

We can access the Ubuntu terminal remotely using SSH. Once the Ubuntu terminal is remotely accessed you can execute the above commands to reboot the Ubuntu server. Go through the following steps to remotely reboot the Ubuntu server:

  1. Open the terminal on the remote server, and use the following SSH command to connect to it:
ssh [username]@[remote_server_ip]
  1. Once you are logged in to the server via SSH, you can execute one of the following commands to reboot the Ubuntu server:
sudo reboot now
sudo shutdown -r 
sudo systemctl reboot
sudo init 6
sudo telinit 6
echo b | sudo tee /proc/sysrq-trigger

Conclusion

To restart Ubuntu from the terminal execute one of the following commands: “sudo reboot”, “sudo shutdown -r”, and “sudo systemctl reboot”. Other than these commands, we can also use the “sudo init 6” or “sudo telinit 6”, to restart Ubuntu. However, these commands were specifically designed for the older Ubuntu versions while in the latest Ubuntu versions the “reboot”, “shutdown -r”, and “systemctl reboot” are commonly used.

We can use the REISUB sequence to reboot an unresponsive Ubuntu machine, but it must be executed carefully (only when necessary) as it can lead to data loss.