Linux Shutdown: Key Differences Between “halt” and “poweroff” Commands Explained


2 views

When working with Linux systems, the shutdown command offers two distinct termination modes: halt and poweroff. While both bring the system down, their underlying behavior differs significantly:

# Basic syntax examples:
shutdown -h now    # Halts the system
shutdown -P now    # Powers off the system

The difference stems from how these commands interact with the system's runlevels and hardware:

  • halt (-h): Stops all CPUs but keeps power on (runlevel 0)
  • poweroff (-P): Stops CPUs AND sends ACPI signal to cut power (runlevel 6)

Consider these practical scenarios:

Use Case Recommended Command
Remote server maintenance shutdown -h +10 "Maintenance window"
Desktop shutdown shutdown -P 22:00
KVM guest shutdown shutdown -h now

Modern systems using systemd have corresponding commands:

systemctl halt      # Equivalent to shutdown -h
systemctl poweroff  # Equivalent to shutdown -P

If -P doesn't power off hardware:

  1. Check ACPI support in BIOS
  2. Test with echo o > /proc/sysrq-trigger (emergency poweroff)
  3. Verify power management packages are installed

Here's a sample script for graceful service termination before shutdown:

#!/bin/bash
case "$1" in
  halt)
    /usr/sbin/service apache2 stop
    /sbin/shutdown -h now
    ;;
  poweroff)
    /usr/sbin/service mysql stop
    /sbin/shutdown -P now
    ;;
esac

When working with Linux systems, the shutdown command offers two distinct modes for stopping your system: halt and power off. While they might seem similar at first glance, their underlying behavior differs significantly.

Halt (-H) stops all CPU processes but keeps the power on. The system reaches runlevel 0 (halt state) where only the kernel remains loaded, waiting for a manual power cycle.

Power off (-P) performs a complete shutdown, sending an ACPI signal to physically cut power to the machine (equivalent to init 0). This is what most users expect from a "shutdown".

Here's how to use these commands:

# Basic halt command
sudo shutdown -h now

# Explicit halt (alternative syntax)
sudo shutdown -H +5 "System halting in 5 minutes"

# Power off command
sudo shutdown -P now

# Modern equivalent (systemd systems)
sudo systemctl poweroff

Use halt when:

  • You need to perform hardware maintenance
  • Running on virtual machines where power management differs
  • Debugging low-level system behavior

Use power off for:

  • Regular workstation shutdown
  • Servers that should fully power down
  • Any situation where you want the machine completely off

The actual difference comes down to the final runlevel and ACPI handling:

# Check current runlevel
who -r

# View shutdown logs
journalctl -u systemd-shutdownd

If your system isn't powering off correctly:

# Force immediate power off (caution!)
echo o > /proc/sysrq-trigger

# Check ACPI status
dmesg | grep -i acpi