Home / Alt manpages / poweroff(8)

  • poweroff(8)
  • Admin command
  • linux

Power Off, Reboot or Halt a systemd Machine Safely

You will finish with a safe way to power off, reboot or halt a systemd machine, and a clear reason to avoid the force option. The examples match the installed systemd-sysv 255.4-1ubuntu8.17 interface, where poweroff, reboot and halt are compatibility commands implemented through systemd.

Allow about ten minutes to read and check the command syntax. You need a shell account with permission to manage the machine. The final power operation normally requires elevated privileges and will interrupt your session, so save work and confirm the target host before running it.

1. Check the command without changing the machine

First confirm which command is installed and read its local help. These are ordinary, read-only checks and do not need sudo:

$ command -v poweroff
/usr/sbin/poweroff
$ readlink -f "$(command -v poweroff)"
/usr/bin/systemctl
$ dpkg-query -W systemd-sysv
systemd-sysv 255.4-1ubuntu8.17
$ poweroff --help
poweroff [OPTIONS...]

Power off the system.

The exact help text can vary between systemd releases. On this installation it identifies the command as a compatibility interface and lists the operation selectors, force mode, wtmp handling and wall-message control. The matching halt(8), poweroff(8) and reboot(8) manuals describe the same option set.

Checkpoint: if command -v finds an unexpected wrapper or an alias, inspect it before continuing. Do not assume that a shell alias has the same behaviour as the system command.

2. Choose the operation you actually mean

Use the command whose name says what should happen:

CommandResultUse it when
poweroffPower off the machineThe host should shut down and turn off
rebootRestart the machineThe host should come back without a full power-off
haltHalt the machine while leaving power onYou specifically need a halt, not a power-off

That last distinction is easy to miss. Older SysV systems often treated halt as another spelling of power-off. systemd documents the more precise behaviour: use poweroff when the machine must actually turn off.

Each command accepts an explicit operation selector. For example, halt --reboot requests a reboot, while poweroff --halt requests a halt. These forms are useful in generated scripts only when the command name is fixed by another interface; for interactive work, the direct command is clearer.

3. Perform a normal, graceful operation

Warning

The following commands stop services and end the current session. A power-off or reboot is not reversible from the shell. Check the hostname, save files and warn other users before proceeding.

For a graceful power-off, use:

$ hostname
server.example.test
$ sudo poweroff

For a restart, substitute reboot:

$ sudo reboot

For a halt that leaves power on:

$ sudo halt

By default these commands hand the request to the init system. The normal path syncs storage, records the shutdown in wtmp and sends the wall message unless you explicitly select different behaviour. You may see a password prompt, a broadcast message or no further shell prompt because the operation has begun.

Checkpoint: a successful command returns status 0, but a machine that is powering off may close the session before you can print that status. From a second management session, verify a reboot with a fresh login and:

$ uptime
 10:42:18 up 1 min,  1 user,  load average: 0.03, 0.02, 0.00

The uptime and load values are examples, not fixed output. For a power-off, the useful verification is that the host no longer accepts connections. If you halted it intentionally, use the console or your remote management system to confirm that power remains available.

4. Understand the options before using them

The ordinary command is usually the safest choice. The following options change its side effects:

  • -w or --wtmp-only writes a shutdown entry but does not halt, reboot or power off. It changes the login accounting file, so use it only when that record is the purpose of the test.
  • -d or --no-wtmp suppresses the shutdown entry. This can make operational auditing less useful and should not be added just to hide noise.
  • --no-wall suppresses the message to logged-in users. Use it only when you have another way to communicate the service interruption.
  • -p or --poweroff selects power-off when invoked as halt or poweroff. It is ignored when invoked as reboot.
  • --halt and --reboot select those operations regardless of the command name.

Use poweroff --help on the target host when you need to check an option. The manual also documents -n or --no-sync, which skips syncing storage. That is a data-integrity risk, not a performance tweak.

5. Treat force mode as an emergency measure

Do not use this as the normal fix for a slow shutdown. sudo poweroff --force, sudo reboot -f and the equivalent halt form request an immediate operation without contacting the init system. The manual warns that filesystems are generally not properly unmounted in this mode.

Before considering force mode, investigate the graceful operation from a separate console or management channel. Look for a blocked service, an unresponsive mount or a storage problem. If you must use force mode to recover a machine, accept that unsaved application data can be lost and filesystem checks may be needed at the next boot.

There is no undo command for a forced operation. Recovery means restoring service after the machine returns, checking system logs and mounted filesystems, and repairing any application state from a known-good backup. If a normal shutdown is merely waiting for a service timeout, wait or fix that service rather than skipping the shutdown sequence.

6. Diagnose the common mistakes

If a normal command fails immediately, check the exit status and the service manager state without repeating the destructive request:

$ sudo poweroff
$ printf 'poweroff status: %s\n' "$?"
poweroff status: 1
$ systemctl is-system-running
degraded

The exact status and diagnostic text depend on the failure. A non-zero status means the request failed; it does not mean the machine is safe to keep using without checking why. Review the terminal message and relevant journal entries with your normal systemd diagnostics.

If you meant to restart but used halt, remember that halt leaves power on. If a script uses a generic command name, make the intended operation explicit with the correct command or selector and test it in a disposable environment first. Never test a shutdown script on a production host merely to discover which branch it takes.

Done means

  • You identified the installed systemd-sysv version and checked the local help.
  • You can distinguish power-off, reboot and halt, including halt's power-on result.
  • You use elevated privileges only for the final operation, after checking the target host.
  • You leave normal storage syncing, wtmp accounting and wall notification enabled unless there is a specific reason not to.
  • You reserve --force and --no-sync for understood emergencies with a recovery plan.