shutdown

system administrationLinux/Unix
The shutdown command is one of the most frequently used commands in Linux/Unix-like operating systems. shutdown Shut down, reboot, or halt the system

Quick Reference

Command Name:

shutdown

Category:

system administration

Platform:

Linux/Unix

Basic Usage:

shutdown [options] [arguments]

Common Use Cases

    Syntax

    shutdown [options] [time] [message]

    Options

    Option Description
    -r Reboot the system
    -h Halt or power off the system (depends on system configuration)
    -H Halt the system (don't power off)
    -P Power off the system (stronger than -h on some systems)
    -c Cancel a pending shutdown
    -k Don't shut down, only send warning messages
    --no-wall Don't send wall message before shutdown
    -f Force file system check on reboot (not supported on all systems)
    -F Force file system check on reboot (alternate syntax on some systems)
    --help Display help message and exit
    Time Format Description
    now Execute shutdown immediately
    +minutes Schedule shutdown in specified number of minutes
    hh:mm Schedule shutdown at the specified time (24-hour format)

    Examples

    How to Use These Examples

    The examples below show common ways to use the shutdown command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    # Basic Examples Basic
    shutdown -h now
    Shut down and halt the system immediately.
    shutdown -r +5
    Reboot the system in 5 minutes.
    shutdown -c
    Cancel a pending shutdown. # Advanced Examples Advanced shutdown -h 23:30 Schedule a system halt at 11:30 PM. shutdown -r +10 "System will reboot for maintenance" Reboot in 10 minutes with a custom message to all users. shutdown -P now Power off the system immediately. shutdown -H now Halt the system without powering off. shutdown -k now "This is just a test" Send warning messages, but don't actually shut down. shutdown -r --no-wall now Reboot immediately without sending a message to users. shutdown -f -r now Force file system check on reboot. shutdown -h +60 Shut down the system in 1 hour. shutdown -r 02:00 Schedule a reboot at 2:00 AM.

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    The `shutdown` command is a system administration utility used to safely shut down, reboot, or halt a Linux or Unix-like operating system. This command ensures that all running processes are properly terminated, filesystems are unmounted, and system services are stopped in an orderly fashion before the system is powered off or restarted. By using the `shutdown` command instead of simply cutting power to the machine, you minimize the risk of data loss, filesystem corruption, and other potential issues that can occur from an abrupt shutdown. Key features of the `shutdown` command include: 1. Scheduled Shutdowns: The command allows administrators to schedule shutdowns for a specific time, either as a delay in minutes or at a particular clock time. This is useful for performing maintenance during off-hours or giving users advance notice. 2. Warning Messages: By default, `shutdown` sends a message to all logged-in users warning them about the impending shutdown, allowing them to save their work and log out gracefully. 3. Cancellation: A scheduled shutdown can be cancelled using the `-c` option, as long as the actual shutdown process hasn't begun yet. 4. Multiple Shutdown Types: The command supports various shutdown modes including complete power-off, halting the system without powering off, and system reboots. 5. Test Mode: Using the `-k` option allows administrators to send warning messages without actually shutting down, which is useful for testing or for warning users about future maintenance. In modern Linux distributions, the `shutdown` command is typically implemented as part of the systemd suite, though it maintains backward compatibility with the syntax from earlier Unix systems. The command requires administrative (root) privileges to execute, typically through sudo or by being logged in as the root user. It's worth noting that different Linux distributions and Unix variants may have slight variations in the available options and exact behavior of the `shutdown` command. Always refer to the man pages (`man shutdown`) on your specific system for the most accurate information. For everyday use, the most common formats are `shutdown -h now` to halt immediately, `shutdown -r now` to reboot immediately, and `shutdown -c` to cancel a pending shutdown.

    Related Commands

    These commands are frequently used alongside shutdown or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the shutdown command works in different scenarios.

    $ shutdown
    View All Commands