shutdown

Learn how to use the shutdown command to safely shut down or reboot your system. Explore options for immediate shutdown, scheduled reboots, and canceling shutdowns.

Shutdown Command

System Shutdown and Reboot

The shutdown command is a fundamental utility in Unix-like operating systems (including Linux and macOS) used to safely halt or restart the system. It allows administrators to schedule these operations and provides a graceful way to power down hardware, ensuring that all running processes are terminated properly and data is saved.

Immediate System Shutdown

To shut down the system immediately, you can use the now argument. This command will initiate the shutdown process without any delay.

shutdown -h now

The -h flag signifies that the system should be halted (powered off).

Immediate System Reboot

Similarly, to reboot the system immediately, you can use the now argument with the -r flag, which stands for reboot.

shutdown -r now

Scheduled System Shutdown and Reboot

The shutdown command also allows you to schedule a shutdown or reboot for a future time. You can specify a time in minutes from the current time using a plus sign followed by the number of minutes.

To reboot the system after 5 minutes:

shutdown -r +5

You can also specify an absolute time (e.g., 22:00) or a relative time (e.g., +10 for 10 minutes from now).

Canceling a Scheduled Shutdown

If you have scheduled a shutdown or reboot and need to cancel it before it occurs, you can use the -c flag.

shutdown -c

This command will abort any pending shutdown or reboot operations.

Understanding Shutdown Options

The shutdown command is a powerful tool for system management. It's crucial to use it correctly to avoid data loss or system instability. Always ensure that critical processes are stopped and that users are notified before initiating a shutdown or reboot. For more detailed information and advanced options, consult the official documentation for your operating system.

For further reading on system administration and command-line utilities, you can refer to resources like: