Debian

How to Properly Shut down or Reboot a Debian 10 System

While the Power switch on your machine might seem to be the most convenient way to power off or reboot your system, it is surely not the safest approach to do so. Our systems are continuously running processes and managing files in the background, even in an apparently idle state. If we abruptly shut down or even reboot our system, the processes might fail to safely close the open files, causing them to get corrupted. Although the file systems are designed to avoid any such situations, a corrupt system file may actually leave your machine in an unstable state. It is thus recommended to “properly” shut down and reboot your system to save yourself from a bothersome filesystem check on the next boot.

Let us explore some ways that you can use, both through the UI and the command line, to safely power off and reboot your Debian 10 Buster system.

Shutting down Your Debian

A safe shut down approach ensures killing of all the processes, unmounting the file system and signaling the kernel for an ACPI power command. Here are some of the ways you can use to power off your Debian:

Using the Application Launcher

Access the Application Launcher through the Super(Windows) key and then search for ‘Power Off’ or ‘Shut Down’ as follows:

As you click on the Power Off result, it invokes the shutdown function and gives you the following options:

Through this dialog you can choose to:

  • Cancel the shutdown request
  • Restart the system
  • Power Off the system
  • If there are any pending software updates, you can select whether you want to install them before powering off or restarting your system.

Through the downward arrow in the top panel

Click on the downward arrow located at the right corner of the top panel and then click on the following power off button:

You can then choose to Power Off the system, restart it, and even cancel the shutdown call if you want to, through the Power Off dialog.

Through the Command Line

The Linux shutdown command can be used to halt, power-off or reboot the machine, depending on which flags and values you are using with it. Let us explore how we can use it to shutdown, abruptly shutdown and timed shutdown our Debian.

Open the Terminal application through the Application Launcher search and then enter the following command in order to shutdown the system:

$ sudo shutdown

As you run this command, the system will prompt you that it has scheduled shutdown for one minute from the time of running the command.

This lets you save any important files that are open. Debian also gets some time to close sensitive system files so that the system stays in a stable state after reboot. During this time, you can cancel the shutdown call by using the following command:

$ sudo shutdown -c

If you want to abruptly shutdown the system, you can use the following command:

$ sudo shutdown -P now

This is not a recommended way of shutting down your system as it is not safe for your file system.

You can also schedule the shutdown process on your system. This can be done through the following use of the shutdown command:

$ sudo shutdown +t

Where t is the time, in minutes, after which Linux will power off your machine

You can, of course, cancel the scheduled shutdown through the ‘shutdown -c’ command as described above.

These were a few ways through which you can safely shutdown your system without compromising the safety of your file system.

Reboot Your Debian

The reboot/restart call to the system is an extension to the shutdown command. Along with all the shutdown procedure, it also invokes a restart process in the end. Restarting becomes necessary in many cases. For example:

  • When a software installation would work only after a reboot.
  • When a configuration change would only take effect after a reboot.
  • When there is a system glitch and the administrator tells you to “try restarting your system”.

We have already seen how the Shutdown dialog on the Debian UI gives us an option to restart our systems. Therefore, we will see how we can use the command line to invoke the reboot process:

Through the Shutdown command

When you use the Linux shutdown command with the ‘r’ flag, it will restart your system instead of shutting it down. This is how you can do so:

$ sudo shutdown -r

For a scheduled restart, you can use the following syntax of the command:

$ sudo shutdown -r +t

Where t is the time, in minutes, after which Linux will restart your system.

Through the Reboot command

The Linux reboot command will restart the system then and there, without waiting for the user to safely close and save any open files and processes. This is how a Debian administrator can use this command to restart the system:

$ sudo reboot

Through the init command

The following use of the init command will restart your system:

$ sudo init 6

The number that you see here with the init command indicates the behavior that your system is supposed to follow.

Init number System behavior
0 Tells your system to power off the machine
1 System enters the rescue mode
2,3,4,5 Start runlevelX.target unit
 

6

Tells your system to restart the machine

Through these various methods described in this article, you can shutdown and reboot your system in a manner that it does not mess with the stability of the files and operating systems.

About the author

Karim Buzdar

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn.