How to reboot Debian using the command line

The Linux operating system can run without rebooting not only for weeks but for years. But sometimes, there is a good reason to reboot your Linux system after a week or two, depending on the situation. Most of the time, there are two main reasons for the reboot. First, the reboot becomes necessary when you install software that requires a reboot to become functional. Secondly, when you update your system or make some configurations that also require a reboot, apart from that, there can be many other reasons for a reboot. Whatever the reason, you should know how to reboot your system so that all changes take effect.

If you are using a GUI version of Linux or physically accessing your system, rebooting the system is not a problem, but if you are using a headless version of the operating system or accessing via SSH and only have command line access. In this case, you should know how to reboot a system from the command line.

This article will cover various commands for rebooting a Debian-based operating system. We are using Debian 12 to describe the procedure described in this article.

  • Using reboot command
  • Using shutdown command
  • Using init command
  • Using proc command

Using reboot command

The quickest way to reboot Debian is by using the reboot command. It powers off and then performs a reboot of a local host or a remote Debian machine. You must have root permission on the system to reboot it. To become root user on Debian, use this command:

su -

To use this command in Debian for a reboot. First, we have to launch the Terminal application in Debian. To do so, go to the Activities tab located in the top left corner of your desktop. Then in the search bar, type terminal. When the Terminal icon appears, click on it to launch it.

Then in the Terminal, type the following command:

$ reboot

Debian reboot

It will immediately power off and then restart the system.

You can also forcefully reboot a system if the reboot command itself might not work. It is similar to pressing the power button of your laptop or PC. Type the following command in Terminal to reboot your system forcefully:

$ reboot -f

Using shutdown command

The shutdown command in Linux as the name implies is used to power off the system. But if we use the –r flag with it, we can use it to reboot the system. Using this command, we also have to add the time argument to tell when to restart the system. Make note that we have to mention the time in minutes.

The syntax of the command to reboot would be:

$ shutdown -r +[time]

When the above command is entered without any time argument, the system will reboot after one minute using the default settings.

$ shutdown -r

Shutdown and reboot now

To reboot the system immediately, use the following command:

$ shutdown -r now

You can also schedule the restart by defining time in minutes.

For instance to schedule a restart after 2 minutes from now, use the below command:

$ shutdown -r +2

Shutdown Debian in a few minutes

To schedule a restart at an exact time e.g 2:10 PM, you can use:

$ shutdown -r 14:10

If you have set up a scheduled reboot, but later you want to cancel it, you can do it using the –c flag. Run the following command in Terminal to cancel a scheduled restart.

$ shutdown -c

Using init command

Init (short for initialization)is the first process that starts when the system boots. It initializes different processes in a Linux system. You can use it to shut down or reboot a Linux. There exist different run levels(from zero to six) that you can use with the init command to controls the system behavior. To reboot a system, use the run level 6 followed by init command as shown below:

$ /sbin/init 6

Shutdown Debian using init command

Using Proc command

Sometimes while working on a remote server where you have no physical access, you run in a situation where the standard reboot does not work or takes a long time. In that case, we will force the kernel to make a reboot by using the magic SysRq key. The SysRq key provides a way to send instructions to the kernel via the /proc virtual file system.

To make use of the SysRq key, use the following command:

$ echo 1 > /proc/sys/kernel/sysrq

Then use the following command to reboot the system

$ echo b > /proc/sysrq-trigger

Shutdown using proc sys

This method should not be used regularly but only when absolutely necessary.

We have discussed different ways for an easy and quick reboot of a Debian machine. The above-explained four methods apply to both local and remote machines. All these commands immediately reboot a system so make sure to save your work before performing a reboot.