How to Change the Power Button Action in Ubuntu

When working on an Ubuntu laptop or desktop PC, accidentally tapping the physical power button on your keyboard or chassis can abruptly shut down your machine or send it into suspend mode, disrupting unsaved work and active downloads. Conversely, some users prefer the power button to immediately prompt a shutdown dialogue rather than putting the computer to sleep.

Ubuntu’s desktop environment (GNOME) allows you to customise the exact behaviour triggered when your computer’s hardware power button is pressed. Here is how to configure the power button action using the graphical Ubuntu Settings menu.

Available Power Button Options in Ubuntu

Depending on your hardware and workflow, you can assign several distinct actions to the physical power key:

  • Power Off / Interactive Dialogue: Displays a confirmation dialogue giving you sixty seconds to cancel, restart, or power off safely.
  • Suspend: Immediately places your computer into a low-power sleep state, preserving open windows in RAM for rapid wake-up.
  • Nothing / Do Nothing: Ignores short physical presses entirely, eliminating accidental power cut-offs if your power button is positioned close to the Delete or Backspace key.

How to Customise the Power Button Behaviour in Ubuntu Settings

To change the power button setting via the desktop interface:

  1. Click on the system status menu in the top-right corner of the Ubuntu top bar (where the battery, network, and volume icons reside).
  2. Click the Settings gear icon.
  3. In the left-hand navigation pane, click on Power.
  4. Scroll down to the section titled General or Suspend & Power Button.
  5. Locate the setting labelled Power Button Behavior (or Power Button Action).
  6. Click the drop-down menu next to it and select your preferred action:
    • Select Suspend if you want your PC to enter sleep mode quickly.
    • Select Power Off to trigger the system shutdown prompt.
    • Select Nothing if you frequently bump the key by mistake.
  7. Close the Settings window to apply the change immediately.

Testing Your New Power Button Behaviour

Ensure you save any open documents, then press your physical power button once briefly. Ubuntu will now execute your selected action seamlessly without unexpected system disruptions.

Note for Laptop Lid Actions

If you also want to configure what occurs when you close your laptop lid, Ubuntu manages lid suspension within the same Power settings menu or via the lightweight GNOME Tweaks utility under the General tab, providing comprehensive control over your portable device’s power profile.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.