How to Stop Ubuntu from Automatically Waking from Sleep

The Restless Machine

Ubuntu is generally excellent at power management, allowing you to suspend (sleep) your computer to save electricity while keeping your session active in memory. However, just like Windows, Ubuntu allows certain hardware peripherals to pull the system out of its suspended state. The most common offender is an overly sensitive optical mouse. If you place your Ubuntu PC to sleep and then accidentally bump the desk, or if a slight vibration shakes the mouse, the operating system detects the movement and automatically wakes the computer back up. This can result in a laptop draining its battery inside a bag, or a desktop monitor glaring brightly in the middle of the night.

Revoking USB Wake Privileges

To ensure your computer stays asleep until you physically press the power button and stop Ubuntu from automatically waking from sleep due to mouse movement, you must disable USB wake triggers.

This requires a quick edit via the terminal. Open your terminal by pressing Ctrl+Alt+T. First, you need to identify your mouse. Type cat /proc/acpi/wakeup and hit Enter. You will see a list of devices (like EHC1, XHC, USB0). Look for devices listed as “enabled”. To disable a USB controller from waking the PC, you must echo its name into that file. For example, if “XHC” (a common USB controller) is enabled, type sudo sh -c "echo XHC > /proc/acpi/wakeup" and hit Enter (provide your password). Run the cat command again; XHC should now say “disabled”. Note: This change resets on reboot. To make it permanent, you must add that echo command to a startup script like /etc/rc.local or create a systemd service.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.