Ubuntu 18.04 – How to shutdown when power button pressed

In Ubuntu 18.04 the ability to automatically shutdown a computer when the power button is pressed was removed.

There is however a workaround – if you set the machine chassis type to “vm” this functionality to restored.

With this method the power button will work even when a user is not logged in.

These steps show how to configure Ubuntu 18.04 to automatically shutdown when the power button is press.

  1. Press Ctrl + Alt + T on your keyboard to open the terminal
  2. Run the following command
  3. hostnamectl set-chassis vm
  4. Restart the computer
  5. Now when the power button is pressed Ubuntu 18.04 will automatically power off

Reference: https://unix.stackexchange.com/questions/242129/how-to-set-power-button-to-shutdown-instead-of-suspend

The OLD Ubuntu 16.04 way …

In Ubuntu 16.04, when you press the power button on your computer you’re prompted with a list of options – this is the “interactive” shutdown.

The steps below show how to change this so that the power button automatically runs a shutdown – without having to use the interactive shutdown prompt.

  1. Press Ctrl + Alt + T on your keyboard to open the terminal
  2. Run the following command
  3. gsettings set org.gnome.settings-daemon.plugins.power button-power 'shutdown'
  4. Close the terminal
  5. The power button will now automatically run the shutdown command.

Related Articles

Leave a Reply

Your email address will not be published.