×

How to Use shutdown Command in Debian 12 – LinuxWays

How to Use shutdown Command in Debian 12 – LinuxWays


If your device is not in use, you should turn it off to improve its performance. Restarting and shutting down your device is also a key task for troubleshooting and completing the installation processes. Linux’s system provides various commands such as reboot, poweroff, halt, and shutdown to restart and power off your Debian system. However, you must ensure that you shut down the system in the right way, as improper shutdown can damage your device and cause data loss.

The shutdown command is a more convenient and secure way to halt or restart your device. It first stops all running services and applications on the system and then shuts down a device. It can reboot, power off, and halt the machine using multiple parameters. Before executing the shutdown command, ensure that your applications exit properly and all the work is saved.

In this guide, we will discuss the shutdown command in Debian 12 and its uses in detail with examples.

Quick Outline

What is shutdown Command in Debian 12

How to Use shutdown Command in Debian 12

Conclusion

What is shutdown Command in Debian 12

It is important to ensure that your system is safely shut down and in Debian 12, you can use the shutdown command to power off the system immediately, or schedule a shutdown. To execute the shutdown command on Debian, you must have sudo privileges, or log in as a root user.

To switch to the root user on Debian 12, use the below-given command:

Otherwise, use the sudo prefix while running the shutdown command in the terminal. The most basic command to shut down the system is written below:

Using the above command, your system will schedule a shutdown and within one minute it will be powered off automatically.

You can customize the shutdown command using the various options. To view the available options that can be used with the shutdown command on Debian, execute the following command:

How to Use shutdown Command in Debian 12

You can use the shutdown command in Debian 12 to:

  • Immediately Shut Down System
  • Shut Down System After Specified Time
  • Shut Down After Sending Message
  • Restart System
  • Cancel the Shut Down Process
  • See Scheduled Shut Down
  • View the Log of the Shut Down

1: Immediately Shut Down System

One minute is the default waiting time to power off the system; if you do not want to wait then use the shutdown command with now argument to immediately turn off the system:

Moreover, you can provide the full path of the shutdown command to power off your Debian immediately:

sudo /usr/sbin/shutdown now

2: Shut Down System After Specified Time

Use the time option with the shutdown command to power off the system after a specified time; it provides the users time to save their work. The basic syntax of using the time argument with the shutdown command is written below:

The two mostly used formats of time are written below:

  • +m (The system will be shutdown after specific minutes)
  • hh:mm (Set the time according to the time zone)

If you run the below command, the system will automatically shut down at 4:20 am:

Note: The date command is used to display the system’s current time according to your time zone.

Run the below command to shut down the Debian 12 after 3 minutes:

3: Shut Down System After Sending Message

If multiple users access your system, it is better to display a message to inform them about the shutdown. This can be done using the message argument along with the time while executing the shutdown command through the following basic syntax:

sudo shutdown <time> <message>

For example, the below command will shut down the system after five minutes and once you execute this command, it will display the mentioned message on the screen of all users:

sudo shutdown +5 “System is going to shut down soon”

This will display a broadcast message to every logged-in user using the same terminal.

4: Restart System

You can also reboot your Debian system by executing the shutdown command with the –r flag. The following command will reboot the system after the default time, one minute:

To reboot the system immediately, use the now argument:

To schedule a system reboot using the shutdown command on Debian, add the time argument. The below command will reboot the system after five minutes:

You can also schedule a system restart by displaying a message on the user’s screen. The following command will reboot the system after five minutes by displaying the mentioned message:

sudo shutdown +5 –r “The system is going to restart”

5: Cancel the Shutdown Process

To cancel the ongoing shutdown process, use the -c flag with the shutdown command:

6: See Scheduled Shutdown

If you want to view the scheduled shutdown on your Debian system, execute the following command:

7: View the Log of the shutdown

The below command will show the log of all the shutdowns since the file was created on your Debian 12:

OR

Conclusion

Shutdown is a process that is carried out every day, and you must ensure that you properly shut down your system to avoid damaging the file system. You can shut down your system from the GUI or through the command line as well. If you want to shut down your Debian system through the terminal, the “sudo shutdown” command is a better option. Using the shutdown command, you can provide messages, schedule a shutdown, and cancel the shutdown at any time. You can also keep and view the shutdown record by executing the “last shutdown” command.



Source link