X

Debian Shutdown Command: How to Shutdown Linux by Command

Spread the love

When you shut down your machine or computer, all software applications, files, programs, and processes are terminated, erasing all data stored in RAM. Occasionally, it is necessary to shut down the system to update packages or perform a system upgrade, followed by a restart. While many individuals are familiar with the graphical user interface (GUI) method for shutting down the system, this article will explore the procedure for shutting down Debian 11 (Linux OS) utilizing the “shutdown” command in the terminal. The shutdown command can be employed in various contexts by incorporating the “time” and “message” parameters. This article will show you how to run the shutdown command on your Linux machine.

Prerequisites

  • SSH root access or a regular system user with sudo privileges

Conventions

# – given commands should be executed with root privileges either directly as a root user or by use of sudo command
$ – given commands should be executed as a regular user

Shutdown Debian Using ‘shutdown’ command.

The shutdown command safely shuts down the system. All logged-in and processing users are notified that the system is shutting down, and no additional logins are allowed. You can choose to shut down your computer immediately or at a later time.

shutdown is just a symbolic link to systemctl, which is aware that invoking it as shutdown should initiate the same processes as systemctl poweroff. The same principle applies to reboot/systemctl reboot.

You can verify this with these commands.

$ sudo which shutdown

It will return an output like this:

/usr/sbin/shutdown

Now, let’s check the executable with this command

$ sudo ls -lh /usr/sbin/shutdown

You will see the output like this:

lrwxrwxrwx 1 root root 14 Aug 25 12:35 /usr/sbin/shutdown -> /bin/systemctl

It means the ‘shutdown’ command is just a symbolic link to ‘systemctl’

Let’s learn about the syntax:

shutdown [options] [time] [message]
options: These are some shutdown options like turning off the power (default option), rebooting the system, or halting.
time: The shutdown process starts at a specific time specified by the time argument.
message: The message option is used to specify a message to be broadcasted to all users.

By running the command mentioned below, your System will be shut down using the shutdown command:

$ sudo shutdown

The system will shut down after 1 minute because if no time argument is specified, “+1” is implied.

Now, the system will shut down after 1 minute.

Besides using the ‘shutdown’ command to shut down your machine, you can also execute this command:

$ sudo systemctl poweroff

The systemctl command does not directly support scheduled shutdowns. Instead, we can use the at or sleep command in combination with systemctl. For example, we can run this:

$ echo 'sudo systemctl poweroff' | at now + 2 minutes

Shutdown Immediately

We can immediately shut down our system without waiting for the default time of 1 minute using the “now” command after shutting down with the command mentioned below:

$ sudo shutdown -h now

Shutdown After N Time

To shut down the system after a specified time, we use time argument with the shutdown command so the syntax becomes:

$ sudo shutdown [time]

Time can have two formats – hh:mm sets the time based on the time zone, and +m shuts down the System after the specified number of minutes.

To shut down the System at 11:50 AM, run the command:

$ sudo shutdown 11:50

The output shows that the System will be shutdown at 11:50:00

To shut down the System after 5 minutes, run the below-mentioned command:

$ sudo shutdown +5

The date command shows the current time.

Shutdown and Send a Message

We can also send a notification at the time of shutdown using the message argument after the time in the shutdown command. The mentioned message will be broadcast at the time of shutdown; execute the below-mentioned command to broadcast the message “System update” with the help of the shutdown command:

$ sudo shutdown +2 "System Update"

This will broadcast a message after the execution of the shutdown command.

Reboot System

We can also reboot our system using the “-r” flag after the shutdown command, as mentioned below:

$ sudo shutdown -r

Since no time is specified, this will start rebooting after the default time of “1 minute.”

Reboot the system by specifying the time and sending a message using the “shutdown” command.
We can also set the time for rebooting as we did for shutdown. To reboot the System after 3 minutes by showing “Update System,” run the command mentioned below:

$ sudo shutdown +3 –r "Update System"

This will start rebooting after 3 minutes and show a message before rebooting.

Cancel shutdown

If you want to cancel shutdown using the “shutdown” command, run the command mentioned below:

$ sudo shutdown -c

That’s it all! You have learned about the Debian shutdown command.

Of course, if you have an active service with us, you don’t have to learn how to shut down or reboot your Debian server — ask our admins, sit back, and relax. Our admins will help you do it immediately upon request. Our experienced system administrators are available 24×7 and will take care of your request immediately. All you need to do is submit a ticket or initiate a live chat session.

If you liked this post about the Debian shutdown command, please share it with your friends on social networks or leave a comment in the comments section.

Categories: Debian
admin:
Related Post