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.
- Press Ctrl + Alt + T on your keyboard to open the terminal
- Run the following command
-
hostnamectl set-chassis vm
- Restart the computer
- Now when the power button is pressed Ubuntu 18.04 will automatically power off
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.
- Press Ctrl + Alt + T on your keyboard to open the terminal
- Run the following command
-
gsettings set org.gnome.settings-daemon.plugins.power button-power 'shutdown'
- Close the terminal
- The power button will now automatically run the shutdown command.
I am using Ubuntu 18.04, and I don’t remember the account password.
So, I tried to restart the pc but both options restart or power off do not work.
Then, I tried as suggested here to open the terminal with Ctrl + Alt + T, but also this option do not work.
Any other suggestion to re-enter my password rebooting the pc?
Thanks,
Gio
doesn’t work at Ubuntu 20 when upgrated from 18