I'm trying to disable ACPI wake on usb in Ubuntu 20.04
So I created a script in /etc/profile.d
-rwxr-xr-x 1 root root 110 May 18 00:23 disable-usb-wake.sh
#!/bin/sh -e
if cat /proc/acpi/wakeup | egrep 'XHC.*enabled'; then
echo "XHC" > /proc/acpi/wakeup
fi
When I start my machine it says permission denied. Why?
Best Answer
As mentioned in the comments,
/etc/profile.d
is being run as the user logging in, so will not have sufficient permissions to modify system configuration. You could add asudo
command there, but that would just mean you'll need to type your password again when you log in - this would be annoying and will also not work if the logging in user is not a system admin. Also, it will not do its job if no one is logging in after boot.There are a few options, including adding
/etc/rc.local
as you mentioned, which was one of the common ways to do this kind of custom "on-boot" jobs before SystemD made the whole/etc/rc*
thing irrelevant.But - if you already have
/etc/rc.local
set up with your script, you can just enable it in SystemD by:/etc/rc.local
is executable. For example by runningchmod a+x /etc/rc.local
. The SystemD compatibility mode will not work otherwise./etc/systemd/system/rc-local.service.d/enable.conf
with the contents below.sudo systemctl enable rc-local
/etc/systemd/system/rc-local.service.d/enable.conf
:Next time your system boot, SystemD will run your custom
/etc/rc.local
.SystemD Alternatives
power/wakeup
" when it sees whatever the XHC is (I think its the onboard XHCI USB hub?), as documented here: https://www.kernel.org/doc/html/v4.13/driver-api/usb/power-management.html