The Linux operating system is capable of working without rebooting for years, not weeks. But sometimes there is a good reason to reboot the Linux system in a week or two, depending on the situation. There are basically two main reasons for rebooting. First, a reboot becomes necessary when you install software that requires a reboot in order to become operational. Secondly, when you upgrade your system or perform some settings that also require a reboot. Other than this, there can be many other reasons for rebooting. Whatever the reason, you need to know how to reboot the system for all changes to take effect.
If you are using a Linux version with a graphical interface or are physically accessing your system, then rebooting the system is not a problem, but if you are using a headless OS version or accessing it via SSH and you only have access from the command line. In this case, you should know how to reboot the system using the command line.
In this article, we will look at various commands for rebooting a Debian-based OS. We will use Debian 10 to describe the procedure mentioned in this article.
- Using the reboot command
- Using the shutdown command
- Using the init Command
- Using the proc Command
Using the reboot command
The fastest way to reboot the Debian OS is to use the reboot command. It shuts down and then reboots the local host or remote Debian computer.
To use this command in Debian to reboot, we must first run the Terminal application in Debian. To do this, go to activity The tab is located in the upper left corner of the desktop. Then in the search bar enter Terminal, When the terminal icon appears, click on it to launch it.
Then in the Terminal, enter the following command:
$ sudo reboot
It will shut down immediately and restart the system.
You can also force a reboot if the reboot command itself may not work. It is like pressing the power button of your laptop or PC. Type the following command in Terminal to force a reboot:
$ reboot –f
The shutdown command in Linux, as the name suggests, is used to shut down the system. But if we use -R mark it, we can use it to reboot the system. Using this command, we must also add the time argument to indicate when to restart the system. Please note that we must mention the time in minutes.
The syntax for the reboot command will be:
$ sudo shutdown -r +[time]
If the above command is entered without any time arguments, the system will reboot after one minute using the default settings.
$ sudo shutdown -r
To reboot the system immediately, use the following command:
$ sudo shutdown -r now
You can also schedule a reboot by specifying the time in minutes.
For example, to schedule a reboot after 2 minutes, use the following command:
$ sudo shutdown -r +2
To schedule a restart at the exact time, for example, 14:10, you can use:
$ sudo shutdown -r 14:10
If you configured a scheduled reboot, but you want to cancel it later, you can do this using -from flag. Run the following command in Terminal to cancel a scheduled restart.
$ sudo shutdown –c
Using the init Command
Init (short for initialization) is the first process that starts when the system boots. It initializes various processes on the Linux system. You can use it to shut down or reboot Linux. There are different launch levels (zero to six) that you can use with the init command to control the behavior of the system. To reboot the system, use runlevel 6 and then the init command, as shown below:
$ /sbin/init 6
Sometimes when working on a remote server where you do not have physical access, you work in a situation where a standard reboot does not work or takes a long time. In this case, we will force the kernel to reboot using the SysRq magic key. The SysRq switch allows you to send instructions to the kernel through the / proc virtual file system.
To use 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
This method should not be used regularly, but only in case of emergency.
We discussed various ways to quickly and easily reboot a Debian machine. The four methods described above apply to both local and remote machines. All these commands reboot the system immediately, so be sure to save your work before rebooting.
How to reboot Debian using the command line