Well yeah i had this problem and I figured out that “systemctl reboot” and “systemctl poweroff” commands work just fine. So only the UI buttons for rebooting and shutdown didn’t work. I wanted to make them work so I asked ChatGPT for a little help:
ME: well systemctl and system reboot does the job i wanted. Im so happy! But now heres another question. If my shutdown and reboot buttons from UI doesnt work well, how can i edit what they do? Best would be if it was some kind of trigger for “systemctl (action)” command
ChatGPT: You can customize what the shutdown and reboot buttons in the UI do by editing the corresponding systemd targets. In most modern Linux distributions, the shutdown and reboot buttons in the UI are handled by the
systemd-logindservice, which listens for power-related events, such as when the power button is pressed or the system is suspended, and takes appropriate action.
To customize what the shutdown and reboot buttons do, you can create a new systemd target and configure it to run the
systemctlcommand with the desired action, such as
systemctl poweroffto power off the system or
systemctl rebootto reboot the system.
Here are the general steps to create a custom systemd target for the shutdown and reboot buttons:
- Create a new systemd target file under the
/etc/systemd/systemdirectory, such as
[Unit] Description=Custom Shutdown Target [Install] WantedBy=multi-user.target [Service] Type=oneshot ExecStart=/usr/bin/systemctl poweroff
This target will execute the
systemctl poweroffcommand when activated.
- Enable the new target by creating a symbolic link to it from the
# ln -s /etc/systemd/system/custom-shutdown.target /etc/systemd/system/poweroff.target
This will override the default
poweroff.targetand make it use the new custom target instead.
- Reload systemd to apply the changes:
# systemctl daemon-reload
Now, when you click on the shutdown button in the UI, it will activate the custom target and run the
Similarly, you can create a custom target for the reboot button by replacing the
Note that these steps may vary slightly depending on your Linux distribution and the specific version of systemd that you are using.
Well I did what he told me to ( was mistake, I know now… I had to learn the hard ways as you can see.) And now the shutdown and reboot buttons in my Gnome UI doesnt work, and when i try to do “systemctl reboot” or “systemctl poweroff” it says: Access Denied… (the same goes for trying it with sudo in front:
$ systemctl poweroff Call to PowerOff failed: Access denied $ sudo systemctl poweroff Call to PowerOff failed: Access denied
Please, if there anyone who could help, it would mean a world to me. If i should provide more information just tell me and I will.
Thanks for your effort.