Linux Commands

How to Use Shutdown Command on Linux: A Shutdown Command Tutorial

Practicing frequently shutting down your computer, especially when not in use, is a good habit. Shutting down the system will close all files and processes and clear the memory. On the other hand, keeping your system on for an extended period of time may result in it behaving abnormally. Besides, a fresh start clears the RAM and removes any bugs in the memory that causes the system to behave strangely.

In Linux, a terminal is a very efficient and secure way to communicate with your system. Tons of commands let you perform various tasks and operations on Linux. We will be focusing on the “shutdown” command with detail and examples in this article.

The Linux shutdown command gives all processes a signal and time to save any progress before the system goes off. The “init” process changes the “runlevel” when prompted by the “shutdown” command. The “init” is the parent of all processes of your system and initiates or closes other processes according to the command user gives to it.

The Linux system can be shut down with a “shutdown” command in different ways. Let’s check how!

Syntax of Shutdown Command:

Shown below is the basic syntax of the “shutdown” command:

$ sudo shutdown [OPTIONS] [TIME] [MESSAGE]

Various options can be used in the place of “[OPTION]”, such as “-h”, which is used to shut down and halt the system, and “-r”, which is used to reboot. Shutdown operation can also be scheduled by specifying the time in the place of the “[TIME]” argument and even a string of a message for all users in the place of “[MESSAGE]”.

For more help about all options, use the following command:

$ sudo shutdown --help

shutdown/1%20copy.png

Using the “shutdown” Command:

In using the “shutdown” command, simply open the terminal and type the command, then press ENTER. The command below will turn off the machine after one minute, which is the default time:

$ sudo shutdown

shutdown/2%20copy.png

Scheduling the Shutdown:

As discussed above, shutdown can also be scheduled by specifying the time, for instance:

$ sudo shutdown 5

shutdown/3%20copy.png

The above command will perform the shutdown operation after 5 minutes. Other than that, the system can also be shut down at a specific time, for example, if you want to schedule a shutdown at 10 AM, then use the following:

$ sudo shutdown 10:00

shutdown/4%20copy.png

And if you want to shut down your system at 10 PM, use the below-given command:

$ sudo shutdown 22:00

shutdown/5%20copy.png

Shutting Down System Immediately:

To immediately shut down the system, use the “now” expression after the “shutdown” command, type the below-mentioned command in the terminal:

$ sudo shutdown now

Or

$ sudo shutdown 0

Shutting Down System with a Custom Message:

This method is useful when there are multiple users. Message string can be used to notify all users about the reason behind the shutdown. It is also important to specify the time when using the “shutdown” command with a custom message, take for example the appended command below:

$ sudo shutdown 10 "The system will shut down in ten minutes for an important upgrade”

shutdown/6%20copy.png

Rebooting system:

Rebooting the system means restarting the system after shutdown. Just like a shutdown, a reboot can also be scheduled with a custom message. Use the “-r” argument with the “shutdown” command to reboot the system:

$ sudo shutdown –r

shutdown/7%20copy.png

And to schedule reboot, as shown in the command below:

$ sudo shutdown –r 10 “The system is rebooting after 10 minutes”

shutdown/8%20copy.png

For the immediate reboot, use the appended command:

$ sudo shutdown -r now

Canceling the Shutdown:

The scheduled shutdown can be canceled anytime using the command mentioned below:

$ sudo shutdown -c

ab/a%20copy.png

The scheduled shutdown process can also be canceled with a message, for example:

$ sudo shutdown -c “Cancelling the upgrade of the system”

ab/b%20copy.png

However, this command cannot be used if you are immediately shutting down your system with the “now” expression.

Conclusion:

In this post, we studied and understood how to use the “shutdown” command with different options. It is also a very effective and risk-free way to close all processes and power off the system. It even allows you to schedule a shutdown and reboot with a message. Although, “shutdown” function can be performed through GUI, performing it through the entire process in the terminal is much more controlled and secured.

About the author

Sam U

I am a professional graphics designer with over 6 years of experience. Currently doing research in virtual reality, augmented reality and mixed reality.
I hardly watch movies but love to read tech related books and articles.