What is the purpose of the shutdown command in Linux?
The shutdown command is used to power off or restart a Linux system. It sends a signal to the system to shut down or restart, and provides options to specify the timing, delay, and reasons for shutting down or rebooting.
The specific functions are as follows:
- Shut down system: By using the shutdown command followed by the parameter “-h”, you can immediately shut down the system.
- To restart the system: by adding the “-r” parameter to the shutdown command, the system can be restarted immediately.
- Schedule system shutdown: By using the shutdown command followed by the parameter “-h” and a specified time option, you can shut down the system at a specific time. For example, using the command “shutdown -h 20:00” will shut down the system at 8:00 PM.
- Schedule system reboot: By adding the parameter “-r” and a time option after the shutdown command, you can reboot the system at a specified time. For example, using the command “shutdown -r 10:30” will reboot the system at 10:30.
- Delaying the shutdown or reboot of the system: By using the shutdown command with the parameters “-h/-r” and delay option, you can schedule the system to shut down or restart after a specified delay time. For example, using the “shutdown -h +10” command will shut down the system in 10 minutes.
- When using the “shutdown” command followed by the parameter “-h/-r” and the reason option, you can send a reason explanation when shutting down or restarting. For example, using the command “shutdown -h now ‘system maintenance'” will immediately shut down the system and send a notification with the reason “system maintenance”.
In conclusion, the shutdown command is an important tool for managing the shutdown or restart of a Linux system, allowing for different shutdown or restart methods to be achieved using various parameters and options.