You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1.8 KiB


This utility is a proxy for poweroff to prevent you from accidentally shutting down the wrong system. It does this by printing a warning message and asking for confirmation followed by a countdown before executing the actual command.

It is most useful when creating an alias for poweroff in your shell, like:

alias poweroff=/usr/local/sbin/poweroff_guard

Important Consideration

If the standard output is not a tty, this behaves exactly like the regular poweroff.


Open a shell in this directory and type make. Optionally, you may want to append any of the following options:

  • POWEROFF_PATH=/path/to/poweroff: Specify a custom (absolute) path for the the real poweroff command. The default is to use the one in your $PATH.
  • COUNTDOWN_SECS=n: Start the countdown timer at n seconds, the default is 10.
  • EXTRA_CFLAGS=...: Append extra flags to the C compiler.

For example:

# build with default options
# build with all custom options
make \
	POWEROFF_PATH=/bin/custom_poweroff \
	EXTRA_CFLAGS="-O2 -march=native"

Watch out: If you want to recompile with different options, you MUST execute a make clean first. Make will erroneously think the binary is already up to date otherwise.


Do the exact same as building, but append install at the end of the command. For example:

# build and install with default options
make install
# build and install with all custom options
make \
	POWEROFF_PATH=/sbin/custom_poweroff \
	EXTRA_CFLAGS="-O2 -march=native" \

Copyright © 2022 anna .

This program is licensed under the 2-clause BSD license. The license text is at the end of the poweroff_guard.c file.