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:
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:
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:
Scheduling the Shutdown:
As discussed above, shutdown can also be scheduled by specifying the time, for instance:
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:
And if you want to shut down your system at 10 PM, use the below-given command:
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:
Or
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:
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:
And to schedule reboot, as shown in the command below:
For the immediate reboot, use the appended command:
Canceling the Shutdown:
The scheduled shutdown can be canceled anytime using the command mentioned below:
The scheduled shutdown process can also be canceled with a message, for example:
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.