I was looking for hours, maybe more, for a solution and i just found it. I want to share it with everyone. This way it will be easier googling this problem to find the solution faster. So, just like the title says, below is the solution.


hit in terminal:

grep . /sys/bus/usb/devices/*/power/wakeup

The result, for me, was to find out that all usb were disabled. So now, type:


sudo su

we have now root privillages.

2.I have 8 usb ports (you do that for as many usb ports you have) ,so:

echo enabled > /sys/bus/usb/devices/usb1/power/wakeup
echo enabled > /sys/bus/usb/devices/usb2/power/wakeup
echo enabled > /sys/bus/usb/devices/usb3/power/wakeup
echo enabled > /sys/bus/usb/devices/usb4/power/wakeup
echo enabled > /sys/bus/usb/devices/usb5/power/wakeup
echo enabled > /sys/bus/usb/devices/usb6/power/wakeup
echo enabled > /sys/bus/usb/devices/usb7/power/wakeup
echo enabled > /sys/bus/usb/devices/usb8/power/wakeup

Go ahead and test it. Now you can wake up from any wireless or wired usb keyboard and mouse.

So then, the reason we must enable all of them, is because in the next step, we will write this in rc.local to execute the command after every reboot, and after reboot some linux distros (maybe all) change the usb ports. We don't have to worry for anything going wrong by enabling all of them, since linux is in suspend or hibernation, it can't use the wifi to download anything, so it won't wake up without we wake it up on purpose.

Next step:


sudo nano /etc/rc.local

and we paste everything from step 2. in there (before the exit 0 of course).

That's it. From now on we can use our wireless usb and mouse to wake up from suspend.

I hope it works for all of you. This guide was made after testing all other possible solutions around the internet.

  • 2
    If you want to figure out which device is which, you can look in /sys/bus/usb/devices/<device id>/product for a text description. – ntc2 Dec 12 '17 at 18:01
  • I enabled all devices in "grep . /sys/bus/usb/devices/*/power/wakeup" but still didn't work. Perhaps it's because the keyboard and mouse are connected indirectly - wirelessly to a dongle which resides on the screen? Screen is connected via USB to the laptop. – AlikElzin-kilaka Mar 21 '18 at 20:42
  • as @ntc2 said, use this to see the description of each: grep . /sys/bus/usb/devices/*/product helped me to figure out what i'm looking at – Ben Yitzhaki May 5 '18 at 9:46
  • If this still doesn't work, make sure your device (keyboard / mouse) still has power when the PC is in sleep mode. If there is no LED on your device, you can use a USB power monitor (can find them about $10 online) to check for power on the USB port. – J Smith May 7 '18 at 21:40
  • The permanent part of this question no longer works with at least ubuntu 18.04. The addition (askubuntu.com/a/874701/516072) to this answer provided by pavlos-theodorou helped for the permanent part in Ubuntu 18.04 – Laurens Oct 14 '18 at 13:33

In addition to my guide above i want to add this information, because i recently discovered that some wireless usb devices after waking up from sleep, they revert back to disable. I repeat, only some usb devices do that, not all. That's why i didn't add this small guide up on my guide.

So you did as i instructed above and your pc successfully wakes up, but later in the day suddenly it doesn't wake up again.


Open a terminal and do :


At your keyboard device id information the 4 first digits are the vendor id and the 4 next digits are the product id (see screenshot) enter image description here

Next do:

sudo nano /etc/udev/rules.d/10-wakeup.rules

Where "wakeup" enter your desired name of the script. Number 10 is the priority in case you have many other udev rules, the lower the number the 'rule' will be executed before the others.

Copy paste this and replace the vendor id and product id with your own wireless keyboard vendor id and product id.

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="062a", ATTRS{idProduct}=="4101" RUN+="/bin/sh -c 'echo enabled > /sys/bus/usb/devices/usb8/power/wakeup'"

*usb8 for me is my wireless keyboard (you can also see that in the screenshot (Bus 008)), replace it with your own.

Ctrl + O to save , Ctrl + X to exit and reboot.

  • 2
    Better to incorporate this into your first answer. – ntc2 Dec 12 '17 at 17:59
  • 1
    they are 2 different things. the 1st one is the answer to the wake up problem. the 2nd one is more like "How to create a rule to execute no boot" and it's just an "extra" since not everyone knows how to do that and there is no simple amateur guide for that. – Pavlos Theodorou Apr 14 '18 at 10:34

Pavlos Theodorou's answer is very helpful. I would like to add that you can find the usb device that your mouse/keyboard is connected to at boot-up by piping dmesg through grep a couple of times, then egrep once, and finally using tail to make sure it was the most recent entry.

Using this method, you don't have to enable wake on ALL usb ports.

I put the following in my /etc/rc.local file and it finds my logitech receiver every time, even if moved from one usb port to another. Just substitute the name of your keyboard or mouse from dmesg in place of "Logitech K270"

KB="$(dmesg | grep "Logitech K270 as" | grep -o -P "usb.{0,5}" | egrep -o ".{0,3}$" | tail -1)"
echo enabled > /sys/bus/usb/devices/${KB}/power/wakeup

This works on boot, but doesn't seem to run on wake from suspend, so I had to put a script file in /lib/systemd/system-sleep/. Create it, set it as globally executable and give it a name that starts with a double digit number between 00 and 99. My script is as follows, again substite your keyboard/mouse verbage from dmesg:


# Action script to enable wake after suspend by keyboard or mouse

if [ $1 = post ]
    KB="$(dmesg | grep "Logitech K270 as" | grep -o -P "usb.{0,5}" | egrep -o ".{0,3}$" | tail -1)"
    echo enabled > /sys/bus/usb/devices/${KB}/power/wakeup

if [ $1 = pre ]
    KB="$(dmesg | grep "Logitech K270 as" | grep -o -P "usb.{0,5}" | egrep -o ".{0,3}$" | tail -1)"
    echo enabled > /sys/bus/usb/devices/${KB}/power/wakeup

For some reason I can't explain, the 'post' sleep if statement only works every other wake-up... but the 'pre' sleep if statement seems to work every time.

protected by Community Jul 24 '18 at 15:00

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.