LinuxCommandLibrary

halt

Stop the system

TLDR

Halt the system

$ halt
copy

Power off the system (same as poweroff)
$ halt [[-p|--poweroff]]
copy

Reboot the system (same as reboot)
$ halt --reboot
copy

Halt immediately without contacting the system manager
$ halt [[-f|--force]]
copy

Write the wtmp shutdown entry without halting the system
$ halt [[-w|--wtmp-only]]
copy

SYNOPSIS

halt [OPTIONS]

PARAMETERS

-p, --poweroff
    Halts the system and then powers it off. This is often the default behavior on modern systems, making the poweroff command synonymous with halt -p.

-f, --force
    Force halt, bypassing some normal shutdown procedures. This does not call the reboot(2) system call. Use with caution as it may prevent proper unmounting of file systems.

-w, --wtmp-only
    Does not actually halt the system, but only writes the wtmp record, indicating a system shutdown event. Useful for logging without an actual halt.

-d, --no-wtmp
    Do not write the wtmp record. This suppresses the logging of the halt event.

-n, --no-sync, -i
    Do not sync disks before halting. This is extremely dangerous and can lead to severe data loss or file system corruption if used without proper understanding of disk buffer flushing.

-h, --help
    Display a help message and exit, showing common usage and available options.

-V, --version
    Display version information of the halt utility and exit.

DESCRIPTION

The halt command is used to shut down or halt the operating system. Historically, it would stop the system without necessarily cutting power, requiring a manual power-off. On modern Linux distributions, especially those using systemd, halt is often a symlink to systemctl or a wrapper around it, behaving identically to poweroff. When executed, it sends signals to processes, unmounts filesystems, and eventually brings the system to a state where the CPU stops execution. Depending on the hardware and kernel support, this state may or may not include automatic power termination. For a complete power down, the --poweroff option or the poweroff command itself is typically used, though often redundant on contemporary systems.

CAVEATS

On many modern Linux distributions that utilize systemd, the halt command is often a symbolic link or a wrapper that simply invokes systemctl poweroff. This means its traditional distinction from poweroff (where halt might leave the machine powered on in a stopped state) is largely obsolete, and it will typically perform a full system power-off. For explicit and future-proof system control, using systemctl poweroff directly is generally recommended. Additionally, using options like --no-sync can bypass critical disk synchronization steps, leading to unrecoverable data loss or filesystem corruption if the system is not already quiescent.

SECURITY AND PERMISSIONS

Executing halt typically requires root privileges (superuser access) to prevent unauthorized system shutdowns by regular users. This is a critical security measure to maintain system availability and integrity. If a non-root user attempts to execute halt, they will usually receive a 'permission denied' error.

RECOMMENDED MODERN USAGE

While halt remains available for backward compatibility and convenience, the contemporary and preferred method for initiating a system shutdown on systemd-based systems is to use systemctl poweroff. This command offers more granular control and is part of the standardized systemd service management framework, which handles dependencies and service termination more robustly during shutdown.

HISTORY

The halt command has been a fundamental utility in Unix-like operating systems since their early days, providing a basic mechanism to stop system execution. Historically, its primary function was to bring the system to a 'halted' state where the CPU would stop, but the power supply might remain active, requiring a manual power off. The poweroff command later emerged to specifically handle automatic power termination. With the widespread adoption of systemd as the init system in major Linux distributions (like Fedora, RHEL, Ubuntu, Debian), the distinct behaviors of halt, poweroff, and reboot have largely converged. They are now often implemented as front-ends or symbolic links to systemctl poweroff, systemctl reboot, etc., ensuring a consistent and integrated shutdown process managed by systemd.

SEE ALSO

Copied to clipboard