How to Restart Ubuntu From Terminal

Restarting Ubuntu after updates, troubleshooting, or routine maintenance is a common practice. It ensures that any changes, such as software updates or configuration modifications, are fully applied, which helps the system run smoothly and efficiently. Moreover, regular reboots are also beneficial for maintaining system health and avoiding problems caused by extended uptime.

Rebooting Ubuntu through the GUI is straightforward, however, if we’re working on a CLI-based Ubuntu server, we can use specific commands to restart the system. In this tutorial, we’ll discuss several commands to reboot Ubuntu from the terminal.

Restarting Ubuntu Using the reboot Command

Ubuntu supports the reboot command, which allows us to restart the system directly from the terminal. It is a convenient and safe way to reboot Ubuntu from the terminal. This command helps protect our data and ensures the system remains intact during the restart. When we run the reboot command, it sends a signal to the system to reboot, causing all running processes and applications to terminate before the system restarts.

The reboot command can be used to restart the system immediately or after some delay. To restart it immediately, we need to run the following command:

sudo reboot now

When we run this command, it asks us to provide the password for the user “anees”. Specify the password and hit the Enter key to restart Ubuntu immediately:

restart Ubuntu immediately

However, if we run the reboot command without any argument it will restart the system after a delay of a few seconds:

sudo reboot

In addition to this, we can force Ubuntu to reboot, but this is not recommended as it can result in the loss of unsaved data. For this purpose, run the reboot command with the “-f” option:

sudo reboot -f

Rebooting Ubuntu Using the shutdown Command

Ubuntu provides a shutdown command that is specifically designed to power off the system. However, we can run this command with the “-r” option to reboot Ubuntu from Terminal:

sudo shutdown -r

When we run this command, it instructs the system to reboot immediately. However, we can also use this command to schedule a reboot:

sudo shutdown -r + min

Here, min represents the minutes after which the system reboots. For instance, the below-mentioned command sets the system to restart in four minutes:

shutdown -r +4

scheduled reboot

We can also cancel the scheduled reboot by running the “shutdown” command with the “-c” option, as shown below:

cancel scheduled reboot

Rebooting Ubuntu Using the systemctl Command

Another way to restart Ubuntu from the terminal is using the “systemctl reboot” command. This command gracefully terminates all processes, services, and applications before restarting the system. To restart Ubuntu using systemctl, run the following command from the terminal:

sudo systemctl reboot

The above-mentioned command utilizes the systemd utility to trigger a controlled system reboot.

Restarting Ubuntu Using the init Command

Ubuntu supported a command-line utility called init to restart the system from the terminal by using runlevel 6. The init command was widely used in earlier Ubuntu versions (with SysVinit) and other Linux distributions to restart the system. However, recent Ubuntu releases primarily utilize systemd, where the “systemctl reboot” command is preferred. To use this command on Ubuntu, type init followed by 6 and then hit enter key:

sudo init 6

We executed this command on Ubuntu 24.04 (the latest Ubuntu version as of August 2024), and it worked perfectly fine.

Restarting Ubuntu Using the telinit Command

The telinit command works similarly to the init command. We can use this command to reboot Ubuntu from the terminal. When we execute “telinit 6” from the Ubuntu terminal, it terminates running processes and reboots the system:

sudo telinit 6

However, it is important to note that modern Linux distributions like Ubuntu use systemd, where “systemctl reboot” is the recommended command.

Restarting Ubuntu via the REISUB Sequence

The REISUB sequence is a method for rebooting a system in emergency situations, particularly when the system becomes unresponsive. It’s a series of keystrokes that forces a reboot, even if the system is unresponsive. Let’s understand the working of each keystroke one-by-one:

  • R: Switches the keyboard to raw keyboard mode, which lets us enter commands directly.
  • E: Terminates and kills all processes except the init process.
  • I: Syncs all mounted filesystems to ensure data consistency.
  • S: Remounts filesystems in read-only mode to prevent further changes.
  • U: Unmounts all filesystems.
  • B: Initiates a reboot.

To use the REISUB sequence in Ubuntu, first, open the terminal, press and hold the “Alt+Prtsc” keys on the keyboard and then type REISUB in sequence:

ALT + PRTSC + REISUB

Alternatively, we can run the “echo b | sudo tee /proc/sysrq-trigger” command to invoke the REISUB sequence directly from the terminal. This command sends a signal to the kernel to initiate a reboot without going through the REISUB keystrokes.

Conclusion

Restarting an operating system ensures that the system runs smoothly. The GUI makes it easy to do, but the command line provides more control and options. In this tutorial, we’ve covered several ways to reboot Ubuntu from the terminal. These methods include using the reboot, shutdown, systemctl, init, and telinit commands. We’ve also explored the REISUB sequence. You can use the command that best fits your needs.

If you’re new to Linux, it’s important to make sure your setup aligns perfectly with your needs. Ultahost can help you with that. We provide Linux VPS hosting with reliable resources, ensuring your tasks run smoothly and quickly.

FAQ

Can we Reboot Ubuntu From the Terminal?
How to Reboot Ubuntu Immediately Using the Terminal?
How to Schedule a System Reboot in Ubuntu Using the Terminal?
How to Cancel Schedule a Reboot in Ubuntu Using the Terminal?
Can we Restart the Ubuntu Server Remotely?
What is the Safest and Easiest Way of Rebooting Ubuntu From the Terminal?
Can We Force a Reboot on Ubuntu, and Is it Safe?

Related Post

How to Install Laravel on Ubuntu 22.04

Laravel is a popular open-source PHP framework used for...

How to Install Django on Ubuntu 22.04

Django is a popular web development framework used on t...

Install Wildcard SSL Certificate on Ubuntu 22

Securing your website with an SSL certificate is import...

How to Set Up RTMP NGINX on Ubuntu Server

RTMP stands for Real-Time Messaging Protocol and is a w...

How to Install ELK Stack on Ubuntu

The ELK Stack, comprising Elasticsearch, Logstash, and ...

How to Install PrestaShop on Ubuntu

PrestaShop is a popular, free, and open-source e-commer...

Leave a Comment