On my system (Ubuntu 20.04) I have installed this Gnome Shell Extension that modifies the style of the power-off options and also adds an option to hibernate, which I occasionally use on my system in place of suspend. While the extension works as expected, every time I want to hibernate, I am prompted for a superuser password in order to proceed, which is annoying. To get rid of the password dialog, I followed this answer and added

my_username ALL=(ALL:ALL) NOPASSWD:/bin/systemctl hibernate

to my sudoers. After this change, I am able to hibernate from command line without password, as expected. However, the corresponding option from said Gnome Shell Extension still prompts me for a password. The code behind the scenes of the extension can be found here. I was unable to find any implementation of the function Util.trySpawnCommandLine, but it appears that it would just call the supplemented command in a shell. Hence, it's not clear to me, why I am still asked for a password. I have checked that which systemctl returns /bin/systemctl. Could it be that commands from the Gnome Shell are executed in a different user context than the logged in user?

PS: Is it considered safe from a security standpoint, anyway, to add above line to the sudoers file?

  • There is a extension extensions.gnome.org/extension/755/hibernate-status-button this does not require root password. If you want to stick with the extension you mentioned.. tweaking that extension can do the job. I suggest you to try that extension, if that works, I can help to integrate the same to your installed extension.
    – PRATAP
    Aug 20, 2021 at 16:32
  • For me the extension, which you suggest, does not work. In Ubuntu 20.04, at least for me, there are no longer those circular buttons to power off. When installing the extension, nothing happens in the menu.
    – ranguwud
    Aug 20, 2021 at 18:40
  • askubuntu.com/a/1260588/739431
    – PRATAP
    Aug 21, 2021 at 2:59
  • For me the extension does not work, too. And hitting ALT+F2 and giving the systemctl hibernate command does not require any password by default. Did you install the extension system wide, or for user only?
    – starkus
    Aug 21, 2021 at 9:18
  • Oh, that was way too fast I guess. The extension does its trick for me without giving a password prompt.
    – starkus
    Aug 21, 2021 at 9:51


You must log in to answer this question.

Browse other questions tagged .