The linux shutdown command does exactly what it says, but with enough options and edge cases that you’ll look foolish in front of your team if you wing it. Whether you’re cutting power on a VPS, scheduling a maintenance window, or trying to cancel that shutdown you just triggered by accident, this guide covers it all.
What Is the Linux Shutdown Command?
The shutdown command lets you safely power off, reboot, or halt your system. It talks to systemd, which in turn initiates the appropriate target state: poweroff.target, reboot.target, or halt.target. Every running service gets a chance to close cleanly before the machine goes down.
Basic syntax:
shutdown [OPTION] [TIME] [MESSAGE]Syntax Breakdown and Options
Here’s what each component does:
- OPTION: Controls the action. Common flags are -P (power off, default), -r (reboot), and -H (halt without powering off).
- TIME: When to execute. Use hh:mm for absolute time, +m for relative minutes, or now as shorthand for +0.
- MESSAGE: A broadcast to all logged-in users. You must supply a TIME arg to attach a message.
If you run shutdown without arguments, the system defaults to +1, meaning it schedules a shutdown one minute out. Five minutes before any timed shutdown, the system creates /run/nologin to block new logins.
How systemd Handles Shutdown Targets
On modern Linux systems, shutdown works as a thin wrapper around systemd. When you run shutdown -r now, systemd activates reboot.target, stops units in reverse dependency order, and kicks off the kernel reboot sequence. If you’re on an older init-based system, the behavior differs, but those are increasingly rare.
Understanding this matters when troubleshooting stuck shutdowns. A service that ignores SIGTERM and doesn’t have a TimeoutStopSec set can hold up the entire process.
How to Shut Down a Linux System
The linux shutdown now command is the fastest path to a powered-off machine. Here are the patterns you’ll actually use.
Immediate Shutdown
Power off immediately with no grace period:
shutdown nowOr equivalently using the explicit power-off flag:
shutdown -P nowBoth cut services and shut down the machine with zero delay. Use this only when you know no one else is logged in and no critical jobs are running.
Scheduled Shutdown by Time or Minutes
Absolute time shutdown (24-hour format):
shutdown 22:30Relative time, minutes from now:
shutdown +15The linux shutdown timer behavior triggers the /run/nologin file five minutes before the scheduled time, which is what prevents new SSH connections from landing on a system that’s about to go down.
Broadcasting a Shutdown Warning Message
Add a message after the time argument to broadcast to all logged-in users via wall:
shutdown +15 "Maintenance window starting. Save your work now."The message goes to every active terminal session. Useful in multi-user environments where you can’t guarantee everyone checks Slack.
How to Reboot Linux via Shutdown
The linux reboot command via shutdown keeps you in a single consistent interface rather than jumping between shutdown, reboot, and systemctl.
Reboot Immediately vs. Scheduled Reboot
Reboot immediately with shutdown -r now:
shutdown -r nowSchedule a reboot at a specific time:
shutdown -r 22:30Reboot in 15 minutes with a broadcast message:
shutdown -r +15 "Rebooting to apply kernel update."Using shutdown -r instead of just reboot gives you the scheduling and messaging features in one command.
Halt vs. Power Off: What Is the Difference?
These two options confuse people because the terms sound the same:
- -H / –halt: Stops all processes and syncs disks but does not send the ACPI power-off signal. The machine stays physically powered on.
- -P / –poweroff: Stops everything AND sends the power-off signal. The machine turns off. This is the default when you run shutdown without a flag.
Halt is useful in virtualized or embedded environments where a hypervisor or external process handles the actual power state. On bare metal, you almost always want -P.
shutdown -H nowHow to Cancel a Scheduled Shutdown
Run the cancel flag to abort a scheduled shutdown or reboot:
shutdown -cYou can also include an optional message to notify logged-in users that the shutdown has been called off:
shutdown -c "Maintenance postponed. Server staying up."Limitations: When Cancel Does Not Work
Shutdown -c only works on scheduled shutdowns. If you ran shutdown now or shutdown +0, there’s nothing to cancel because the process already started. In that case, you either need to interrupt the terminal process or accept the shutdown.
Also, the cancel command requires appropriate privileges. Running it as a non-root user without sudo will fail silently or throw a permissions error depending on your distro.
Security Benefits of Controlled Shutdowns
A linux shutdown command used properly isn’t just a convenience, it’s part of how you keep a server secure and stable.
Applying Security Patches Safely with Reboot
Many kernel and glibc updates don’t take effect until the system reboots. Skipping the reboot leaves you running a vulnerable kernel even though the package is installed. Scheduling reboots via shutdown -r during low-traffic hours means you apply patches without surprising users and without the chaos of an unplanned outage.
Check which updates require a reboot with:
needs-restarting -r # RHEL/CentOS
cat /var/run/reboot-required # Debian/UbuntuPreventing Data Loss During Shutdown
The reason you use shutdown instead of just cutting power is process termination order. A graceful shutdown sends SIGTERM to services, waits for them to close cleanly, flushes filesystem buffers, and unmounts volumes in the correct sequence. Yanking power skips all of that.
Database corruption from a dirty shutdown is a real thing. A PostgreSQL or MySQL instance that doesn’t get a clean SIGTERM can require replay of its WAL or redo logs on restart, and if those are damaged, you’re in recovery mode. Use the shutdown command. Every time.
FAQ: Linux Shutdown Command
Run: shutdown now or shutdown -P now. Both power off the machine immediately with no grace period.
The -h flag is an alias for –poweroff on most modern systems, so shutdown -h now powers off the machine immediately. On some older systems -h mapped to –halt. Use -P now if you want to be explicit about the power-off behavior.
Use shutdown -c to cancel any pending scheduled shutdown or reboot. This won’t work if the shutdown already started (i.e., was triggered with now or +0).
Halt stops all processes and syncs disks but doesn’t send the ACPI power-off signal, so the hardware stays on. Poweroff does everything halt does and then turns off the machine. On bare metal, you almost always want poweroff.
Use shutdown with a time argument: shutdown 22:30 for an absolute time in 24-hour format, or shutdown +15 to schedule it 15 minutes from now. Combine with a message to warn users: shutdown +15 “Server going down in 15 minutes.”