Polecenia Linuksa

How to Use Shutdown Command on Linux A Shutdown Command Tutorial

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

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

Scheduling the Shutdown:

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

$ sudo shutdown 5

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

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

$ sudo shutdown 22:00

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”

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

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

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

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

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

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

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.

Emulate Mouse clicks by hovering using Clickless Mouse in Windows 10
Using a mouse or keyboard in the wrong posture of excessive usage can result in a lot of health issues, including strain, carpal tunnel syndrome, and ...
Add Mouse gestures to Windows 10 using these free tools
In recent years computers and operating systems have greatly evolved. There was a time when users had to use commands to navigate through file manager...
Control & manage mouse movement between multiple monitors in Windows 10
Dual Display Mouse Manager lets you control & configure mouse movement between multiple monitors, by slowing down its movements near the border. Windo...