LinuxCommandLibrary

shutdown

Power down or restart the system

TLDR

Power off ([h]alt) immediately

$ shutdown -h now
copy

Reboot immediately
$ shutdown [[-r|--reboot]] now
copy

Reboot in 5 minutes
$ shutdown [[-r|--reboot]] +[5] &
copy

Shutdown at 1:00 pm (Uses 24h clock)
$ shutdown -h 13:00
copy

Cancel a pending shutdown/reboot operation
$ shutdown -c
copy

SYNOPSIS

shutdown [OPTIONS...] [TIME] [MESSAGE]

PARAMETERS

-r
    Reboot after shutdown.

-h
    Halt or power off after shutdown (default).

-P
    Power off after shutdown. Equivalent to -h on most systems but ensures power-off on some.

-k
    Don't actually shut down; only send the warning messages to users.

-c
    Cancel a pending shutdown.

-t SEC
    Delay between warning and shutdown (in seconds).

TIME
    Shutdown time. Can be 'now' for immediate shutdown, '+m' for shutdown in m minutes, or 'hh:mm' for shutdown at a specific time.

MESSAGE
    A message to send to all logged-in users before shutdown.

DESCRIPTION

The shutdown command in Linux is used to bring the system down in a controlled manner. It's a crucial command for system administrators to ensure data integrity and prevent corruption during system halt or reboot. Unlike simply cutting the power, shutdown signals running processes, allowing them to save data and exit gracefully. It can be used to halt, reboot, or power off the system, and can also be scheduled to occur at a specified time or after a specified delay. The command often requires root privileges or appropriate sudo configuration, because shutting down the system impacts all users and running services. A warning message is typically broadcast to all logged-in users before the shutdown commences. The shutdown command uses systemd by default on systems that are based on it, but depending on the system's init process it may use other tools to initiate the shutdown sequence.

CAVEATS

Improper use of shutdown, especially without a proper time delay, can lead to data loss if processes are not given sufficient time to save their state. On systems using systemd, the behavior might differ slightly from traditional SysVinit systems.

EXAMPLES

shutdown -h now: Immediately halt the system.
shutdown -r +10: Reboot the system in 10 minutes.
shutdown -P 23:00 "System maintenance": Power off the system at 11 PM with a message.

SIGNALS

The shutdown command sends signals to running processes to initiate a clean exit. This avoids abrupt terminations that can cause data loss.

HISTORY

The shutdown command has been a core part of Unix and Linux systems since their early days. Its primary function has always been to provide a safe and controlled way to bring down the system, preventing data corruption. Over time, the command has been adapted to work with various init systems, most recently systemd.

SEE ALSO

reboot(8), halt(8), poweroff(8), systemctl(1)

Copied to clipboard