My dualboot (Win11+Manjaro) doesnt shutdown and reboot properly, and I messed up fixing it

HI!
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-logind service, 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 systemctl command with the desired action, such as systemctl poweroff to power off the system or systemctl reboot to reboot the system.
Here are the general steps to create a custom systemd target for the shutdown and reboot buttons:

  1. Create a new systemd target file under the /etc/systemd/system directory, such as /etc/systemd/system/custom-shutdown.target:
    makefileCopy code
[Unit]
Description=Custom Shutdown Target

[Install]
WantedBy=multi-user.target

[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl poweroff

This target will execute the systemctl poweroff command when activated.

  1. Enable the new target by creating a symbolic link to it from the poweroff.target:

shellCopy code

# ln -s /etc/systemd/system/custom-shutdown.target /etc/systemd/system/poweroff.target

This will override the default poweroff.target and make it use the new custom target instead.

  1. Reload systemd to apply the changes:

arduinoCopy code

# systemctl daemon-reload

Now, when you click on the shutdown button in the UI, it will activate the custom target and run the systemctl poweroff command.
Similarly, you can create a custom target for the reboot button by replacing the ExecStart line with ExecStart=/usr/bin/systemctl reboot.
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.

Just undo what you did and reboot. Since you only made symlinks and new files instead of edited old ones, simply remove them.

edit: if your problem is the systemctl commands not working for achieving reboot, you can try “reboot” command or “shutdown” command.

1 Like

Can we add a blocklist for this type of question? Nothing good ever comes from this.

It’s weird to blindly copy things from a random user and now there are people who copy hallucinated output from a stochastic process that somehow convinced people that it’s superior.

Don’t do this. Understand your system.

1 Like

worst of all is that sometimes chatgpt gets things right, then other times it gets things confidently wrong. A human would need to exert considerable deceptive effort to be as confidently wrong.

1 Like

SOLVED! Only problem was that i had in “/etc/systemd/system” some corrupted file “poweroff.target” that I removed and it works now. Thanks to everyone for effort!

Hi and welcome to the Forum :+1:


Next time ask the experts first before asking an AI-Bot :rofl:

If you had performed systemctl cat poweroff.target, you would have seen this:

# /lib/systemd/system/poweroff.target
#  SPDX-License-Identifier: LGPL-2.1-or-later
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=System Power Off
Documentation=man:systemd.special(7)
DefaultDependencies=no
Requires=systemd-poweroff.service
After=systemd-poweroff.service
AllowIsolate=yes
JobTimeoutSec=30min
JobTimeoutAction=poweroff-force

[Install]
Alias=ctrl-alt-del.target

Which would have meant you can just create a systemd-poweroff.service inside /etc/systemd/system/ to override the system service and perform the action you want…

1 Like

If we see users posting ChatGPT answers without mentioning that’s the source, the posts will most likely be deleted. We have had internal discussion about this among the Moderators. We will continue to monitor and see if we need to add a new forum rule.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.