Chapter 6. Changing how your system behaves when you press the power button

When you press the power button on your computer, it shuts down the system by default. You can customize this behavior according to your preferences.

Prerequisites

  • Administrative access.

Procedure

  1. Open the /etc/systemd/logind.conf configuration file.
  2. Look for the line that says HandlePowerKey=poweroff.
  3. If the line starts with the # symbol, remove it to enable the setting.
  4. Replace poweroff with one of the following options:

    • poweroff to shut down the computer.
    • reboot for a system reboot.
    • halt to initiate a system halt.
    • kexec for a kexec-based reboot.
    • suspend to suspend the system.
    • hibernate to initiate system hibernation.
    • ignore to do nothing.

    For example, to reboot the system upon pressing the power button, use this setting:

    HandlePowerKey=reboot
  5. Save your changes and close the editor.