shutdown – The Command to Perform a System Shutdown

The shutdown command is used to shut down or reboot a Linux system. It is a powerful command that requires root privileges to execute. This command is useful for system administrators who need to shut down or reboot multiple systems remotely.

Overview

The shutdown command can be used in several ways. The most basic syntax is:

shutdown [OPTION] [TIME] [MESSAGE]

In this syntax, [OPTION] refers to the various options that can be used with the command, [TIME] refers to the time at which the system will be shut down or rebooted, and [MESSAGE] refers to the message that will be displayed to all users before the system is shut down or rebooted.

Here is an example of how to use the shutdown command to shut down a system immediately:

sudo shutdown now

This command will immediately shut down the system. The sudo command is used to run the shutdown command with root privileges.

Here is an example of how to use the shutdown command to shut down a system at a specific time:

sudo shutdown -h 23:00 "System will shut down at 11 PM"

This command will shut down the system at 11 PM and display the message “System will shut down at 11 PM” to all users.

Options

The shutdown command has several options that can be used to customize its behavior. Here is a table of the available options:

Option Description
-h Halt the system (shut down)
-r Reboot the system
-k Send a warning message to all users, but do not shut down or reboot the system
-c Cancel a pending shutdown or reboot
-t Set the time until shutdown or reboot (in minutes)
-f Force all processes to terminate
-n Do not sync the file system before shutting down or rebooting
-w Only write the shutdown or reboot time to the utmp file

Troubleshooting Tips

If the shutdown command does not work as expected, there are a few things you can try:

  • Make sure you are running the command with root privileges (sudo).
  • Check that there are no active processes that are preventing the system from shutting down or rebooting.
  • If you are using the -t option to set a time until shutdown or reboot, make sure it is set to a valid value (in minutes).
  • If the system does not shut down or reboot, try using the -f option to force all processes to terminate.

Notes

  • The shutdown command can be used to shut down or reboot a local system or a remote system (using SSH).
  • The shutdown command can also be used to schedule a shutdown or reboot at a specific time (using the -t option).
  • The shutdown command can be used in combination with other commands (such as cron) to automate system shutdowns or reboots.