What is the Linux shutdown Command?
In Linux, the shutdown command is devoted to shutting down and restarting the device. It too can carry out further duties like scheduled shutdown or reboot. It’s to be had on all of the Linux distros. The shutdown command sends a notification to all of the device’s operating processes and energetic customers on the time of motion. It additionally prevents any new consumer from logging in. It’s a safe means of shutting down or rebooting the gadget.
This information will reveal probably the most maximum commonplace techniques of the use of the shutdown command in Linux.
Linux shutdown command
The shutdown command calls for root permission to close down or reboot the device. To use it, make certain that you’ve gotten get right of entry to to a consumer account that may carry out administrative duties. Learn how you can grant non-root customers sudo permission.
Basic command construction
Here’s the bottom command construction.
$ shutdown choices> time> message>
Here,
: Specifies the behaviour of shutdown command, for instance, rebooting, power-off, and so forth. : All the customers will obtain this message as a notification for the approaching shutdown/reboot tournament.
Many fashionable distros changed the unique shutdown instrument with a shutdown alias to systemctl. It’s nonetheless to be had just for compatibility causes.
Shutting down the device
If no argument is supplied, then shutdown will close down the device 1 minute after the command run.
It’s additionally an identical to the flag “-P” or “–poweroff”.
Cancelling scheduled shutdown
Whenever operating a shutdown command, it is going to in most cases time table the duty a couple of mins sooner or later. In the period in-between, if essential, we will be able to cancel the duty by way of operating the next command.
The flag “-c” tells to cancel any scheduled shutdown/restart of the device.
Restarting the device
Despite the identify, the shutdown command can reboot the device. To restart the device, use the flag “-r” or “–reboot”.
Scheduling a shutdown
As demonstrated previous, the shutdown will time table the duty described one minute into the longer term. However, we will be able to manually set the time of performing.
For instance, the next shutdown command will close down the device at 10:00 AM. Note that shutdown makes use of a 24-hour layout in the case of timing.
Alternatively, we will be able to time table a device shutdown after a definite collection of mins. In the next instance, the device is scheduled to close down after 250 mins.
Scheduling a restart
Similar to scheduling device shutdown, we will be able to additionally time table a device restart. The following command will time table a device restart at 9:00 AM.
Alternatively, inform shutdown to restart the device after a number of mins.
Immediate shutdown/restart
So some distance, we’ve noticed how you can time table a shutdown/reboot. In many scenarios, it’s essential to behave straight away. There are two kinds of time values that shutdown helps for this objective.
Shutdown helps “now” as a legitimate time. As the label suggests, the motion can be performed straight away.
If you insist on the use of a numeric price, then we will be able to additionally describe “now” as “+0”. Basically, the shutdown will act after 0 mins (straight away, in different phrases).
Broadcasting customized message
Whenever any shutdown command is issued, it is going to broadcast a message to the entire device. It’s designed to inform in regards to the upcoming motion to all of the customers these days logged in. By default, the shutdown command will ship a message that appears one thing like this.
However, we will be able to additionally ship a customized message to all of the customers. To use a customized message, use the next command construction.
$ sudo shutdown +250 “
Note that each time you need to broadcast a customized message, it will have to be accompanied by way of a particular time argument.
Here are a couple of examples of the use of customized messages with more than a few shutdown/restart duties.
$ sudo shutdown -r +25 “kernel update”
$ sudo shutdown +5 “system shutdown.”
$ sudo shutdown -c “operation cancelled”
Final ideas
Linux shutdown command is a simplistic instrument. This information demonstrates the use of the shutdown command to time table shutdown and reboot with customized shutdown messages.
The shutdown guy web page describes all of the to be had shutdown arguments in-depth.
Happy computing!