How to Restart Debian Using the Command Line
The Linux operating system can run without a reboot not only for a few weeks but for years. But sometimes there's a good reason to reboot your Linux system after a week or two, depending on the situation.
In this article, Tipsmake will cover various commands for rebooting a Debian-based operating system.
Note: Debian 11 is being used to describe the process in this article.
Use the command reboot
The fastest way to restart Debian is to use the reboot command. Command to power off and then do a reboot of the local server or the remote Debian machine. You must have root privileges on the system to restart it. To become the root user on Debian, use the following command:
su -
To use this command to restart Debian, first launch the Terminal application in Debian. To do so, go to the Activities tab located at the top left corner of the screen. Then in the search bar, type terminal. When the Terminal icon appears, click on it to launch the tool.
Then, in Terminal, type the following command:
$ reboot
It will immediately power off and then reboot the system.
You can also force a system reboot if the reboot command itself doesn't work. It is similar to pressing the power button of a laptop or PC. Enter the following command in Terminal to force restart the system:
$ reboot -f
Use the shutdown command
The shutdown command in Linux as its name implies is used to shut down the system. But if you use the –r flag with it, you can use the command to reboot the system. Using this command, you must also add a time argument to indicate when to restart the system. Please note that time must be mentioned in minutes.
The syntax of the restart command would be:
$ shutdown -r +[time]
When the above command is entered without any time argument, the system will reboot after one minute using default settings.
$ shutdown -r
To reboot the system immediately, use the following command:
$ shutdown -r now
You can also schedule a restart by specifying the time in minutes.
For example, to schedule a reboot 2 minutes from now, use the command below:
$ shutdown -r +2
To schedule a restart at an exact time, say, 2:10 pm, you can use:
$ shutdown -r 14:10
If you have a scheduled restart set up, but then want to cancel it, you can do so using the –c flag. Run the following command in Terminal to cancel the scheduled reboot.
$ shutdown -c
Using the init . command
Init (short for initialization) is the first process that starts when the system boots. It initializes various processes in the Linux system. You can use it to shut down or restart Linux. There are different run levels (from 0 to 6) that you can use with the init command to control system behavior. To reboot the system, use run level 6 followed by the init command as shown below:
$ /sbin/init 6
Using the proc . command
Sometimes while working on a remote server that you don't have physical access to, you come across a situation where the standard reboot doesn't work or takes a long time. In that case, we will force the kernel to reboot using the magic SysRq key. The SysRq key provides a way 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 often, but only when absolutely necessary.
The article discussed different ways to reboot Debian machine easily and quickly. The 4 methods explained above apply to both local and remote machines. All of these commands immediately reboot the system, so make sure to save your work before doing the reboot.
You should read it
- How to install Debian on a computer
- How to upgrade Debian
- How to use the grep command on Debian 10
- How to Install Gradle on Debian 10
- Instructions for using dpkg command on Linux Debian
- Notable changes and additions in Debian 11 'Bullseye'
- Do not destroy the Debian system!
- Debian 10 Buster, New features in Debian 10 Buster
- How to reset the password for sudo in Debian
- 9 best Debian-based Linux distributions
- How to Install and Use Ansible on Debian 10
- How to Install Debian
Maybe you are interested
Why do most rockets launch near the equator? How to create permanent tab groups in Google Chrome 9 practical applications of ChatGPT in programming Should iPhone 11, 11 Pro users upgrade to iPhone 13? Tips to Make perform Laptop keyboard quick fix How to increase HDD capacity of VirtualBox with Clonezilla