Controlling a USB power supply (on/off) with linux











up vote
142
down vote

favorite
82












Is it possible to turn on/off power supplies from USB manually with linux?



There's this external USB cooling fan (the kind you use to cool yourself off, not the PC), and it would be nice to be able to control it from the terminal, because I want to position the fan somewhere far away.



I suppose this could also be useful for a variety of other things as well, because there's a lot of USB toys out there. Maybe air purifiers etc (I heard they don't really work though).










share|improve this question


















  • 7




    Let me recap for Linux >= 2.6.38: The file power/level is deprecated now; use power/control instead. (power/wakeup is ok.) Furthermore, it accepts only "auto" and "on", not "suspend" any more. "auto" is smart enough, and if the power isn't turned off while idle, it's the device's fault. Anyway you can't turn the power off manually. For more, see the answer below by tlwhitec and the kernel's doc: kernel.org/doc/Documentation/usb/power-management.txt
    – teika kazura
    Jul 4 '13 at 6:51










  • Possible duplicate of stackoverflow.com/q/1163824/1967396
    – Floris
    Apr 13 '14 at 4:32






  • 2




    This feature really deserves a good GUI
    – mikebabcock
    Dec 5 '14 at 5:28










  • Does it require any special hardware? It is not quite clear from answers,
    – Vojtěch Dohnal
    Jun 14 '16 at 4:47















up vote
142
down vote

favorite
82












Is it possible to turn on/off power supplies from USB manually with linux?



There's this external USB cooling fan (the kind you use to cool yourself off, not the PC), and it would be nice to be able to control it from the terminal, because I want to position the fan somewhere far away.



I suppose this could also be useful for a variety of other things as well, because there's a lot of USB toys out there. Maybe air purifiers etc (I heard they don't really work though).










share|improve this question


















  • 7




    Let me recap for Linux >= 2.6.38: The file power/level is deprecated now; use power/control instead. (power/wakeup is ok.) Furthermore, it accepts only "auto" and "on", not "suspend" any more. "auto" is smart enough, and if the power isn't turned off while idle, it's the device's fault. Anyway you can't turn the power off manually. For more, see the answer below by tlwhitec and the kernel's doc: kernel.org/doc/Documentation/usb/power-management.txt
    – teika kazura
    Jul 4 '13 at 6:51










  • Possible duplicate of stackoverflow.com/q/1163824/1967396
    – Floris
    Apr 13 '14 at 4:32






  • 2




    This feature really deserves a good GUI
    – mikebabcock
    Dec 5 '14 at 5:28










  • Does it require any special hardware? It is not quite clear from answers,
    – Vojtěch Dohnal
    Jun 14 '16 at 4:47













up vote
142
down vote

favorite
82









up vote
142
down vote

favorite
82






82





Is it possible to turn on/off power supplies from USB manually with linux?



There's this external USB cooling fan (the kind you use to cool yourself off, not the PC), and it would be nice to be able to control it from the terminal, because I want to position the fan somewhere far away.



I suppose this could also be useful for a variety of other things as well, because there's a lot of USB toys out there. Maybe air purifiers etc (I heard they don't really work though).










share|improve this question













Is it possible to turn on/off power supplies from USB manually with linux?



There's this external USB cooling fan (the kind you use to cool yourself off, not the PC), and it would be nice to be able to control it from the terminal, because I want to position the fan somewhere far away.



I suppose this could also be useful for a variety of other things as well, because there's a lot of USB toys out there. Maybe air purifiers etc (I heard they don't really work though).







linux usb






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 15 '11 at 21:19









kamziro

2,90174267




2,90174267








  • 7




    Let me recap for Linux >= 2.6.38: The file power/level is deprecated now; use power/control instead. (power/wakeup is ok.) Furthermore, it accepts only "auto" and "on", not "suspend" any more. "auto" is smart enough, and if the power isn't turned off while idle, it's the device's fault. Anyway you can't turn the power off manually. For more, see the answer below by tlwhitec and the kernel's doc: kernel.org/doc/Documentation/usb/power-management.txt
    – teika kazura
    Jul 4 '13 at 6:51










  • Possible duplicate of stackoverflow.com/q/1163824/1967396
    – Floris
    Apr 13 '14 at 4:32






  • 2




    This feature really deserves a good GUI
    – mikebabcock
    Dec 5 '14 at 5:28










  • Does it require any special hardware? It is not quite clear from answers,
    – Vojtěch Dohnal
    Jun 14 '16 at 4:47














  • 7




    Let me recap for Linux >= 2.6.38: The file power/level is deprecated now; use power/control instead. (power/wakeup is ok.) Furthermore, it accepts only "auto" and "on", not "suspend" any more. "auto" is smart enough, and if the power isn't turned off while idle, it's the device's fault. Anyway you can't turn the power off manually. For more, see the answer below by tlwhitec and the kernel's doc: kernel.org/doc/Documentation/usb/power-management.txt
    – teika kazura
    Jul 4 '13 at 6:51










  • Possible duplicate of stackoverflow.com/q/1163824/1967396
    – Floris
    Apr 13 '14 at 4:32






  • 2




    This feature really deserves a good GUI
    – mikebabcock
    Dec 5 '14 at 5:28










  • Does it require any special hardware? It is not quite clear from answers,
    – Vojtěch Dohnal
    Jun 14 '16 at 4:47








7




7




Let me recap for Linux >= 2.6.38: The file power/level is deprecated now; use power/control instead. (power/wakeup is ok.) Furthermore, it accepts only "auto" and "on", not "suspend" any more. "auto" is smart enough, and if the power isn't turned off while idle, it's the device's fault. Anyway you can't turn the power off manually. For more, see the answer below by tlwhitec and the kernel's doc: kernel.org/doc/Documentation/usb/power-management.txt
– teika kazura
Jul 4 '13 at 6:51




Let me recap for Linux >= 2.6.38: The file power/level is deprecated now; use power/control instead. (power/wakeup is ok.) Furthermore, it accepts only "auto" and "on", not "suspend" any more. "auto" is smart enough, and if the power isn't turned off while idle, it's the device's fault. Anyway you can't turn the power off manually. For more, see the answer below by tlwhitec and the kernel's doc: kernel.org/doc/Documentation/usb/power-management.txt
– teika kazura
Jul 4 '13 at 6:51












Possible duplicate of stackoverflow.com/q/1163824/1967396
– Floris
Apr 13 '14 at 4:32




Possible duplicate of stackoverflow.com/q/1163824/1967396
– Floris
Apr 13 '14 at 4:32




2




2




This feature really deserves a good GUI
– mikebabcock
Dec 5 '14 at 5:28




This feature really deserves a good GUI
– mikebabcock
Dec 5 '14 at 5:28












Does it require any special hardware? It is not quite clear from answers,
– Vojtěch Dohnal
Jun 14 '16 at 4:47




Does it require any special hardware? It is not quite clear from answers,
– Vojtěch Dohnal
Jun 14 '16 at 4:47












9 Answers
9






active

oldest

votes

















up vote
59
down vote



accepted










Note. The information in this answer is relevant for the older kernels (up to 2.6.32). See tlwhitec's answer for the information on the newer kernels.



# disable external wake-up; do this only once
echo disabled > /sys/bus/usb/devices/usb1/power/wakeup

echo on > /sys/bus/usb/devices/usb1/power/level # turn on
echo suspend > /sys/bus/usb/devices/usb1/power/level # turn off


(You may need to change usb1 to usb n)



Source: Documentation/usb/power-management.txt.gz






share|improve this answer



















  • 1




    Whoa, thanks for that. I was thinking I had to go through libUSB no matter what. Any idea how to get the names of the attached devices as well?
    – kamziro
    Jan 15 '11 at 21:56






  • 2




    @kamziro: try lsusb
    – Roman Cheplyaka
    Jan 15 '11 at 23:53






  • 7




    Doesn't work in Linux Ubuntu 2.6.32-26-generic
    – NoBugs
    Dec 31 '11 at 20:48






  • 5




    I'm getting permission denied error even if I use sudo!
    – Wally
    Jul 26 '14 at 7:52






  • 2




    same for me " permission denied" even after using sudo
    – Raulp
    Mar 4 '15 at 12:03


















up vote
53
down vote













According to the docs, there were several changes to the USB power management from kernels 2.6.32, which seem to settle in 2.6.38. Now you'll need to wait for the device to become idle, which is governed by the particular device driver. The driver needs to support it, otherwise the device will never reach this state. Unluckily, now the user has no chance to force this. However, if you're lucky and your device can become idle, then to turn this off you need to:



echo "0" > "/sys/bus/usb/devices/usbX/power/autosuspend"
echo "auto" > "/sys/bus/usb/devices/usbX/power/level"


or, for kernels around 2.6.38 and above:



echo "0" > "/sys/bus/usb/devices/usbX/power/autosuspend_delay_ms"
echo "auto" > "/sys/bus/usb/devices/usbX/power/control"


This literally means, go suspend at the moment the device becomes idle.



So unless your fan is something "intelligent" that can be seen as a device and controlled by a driver, you probably won't have much luck on current kernels.






share|improve this answer





















  • It seems this will cause the USB device to continuously get powered off...(?) How should power be resumed by me, after this worked? My goal is to restart the device once, not to permanently change its suspension configuration.
    – matanster
    Aug 16 '13 at 17:27








  • 3




    To resume a suspended device, you can disable again the "autosuspend" with echo "on" > "/sys/bus/usb/devices/usbX/power/control", but I think you need to understand the original purpose. The autosuspend feature is here merely to enable idling devices to enter a low-power state (where it might appear turned off), only to be resumed later when it's needed, either by the host or some external event. That happens (or should happen) automatically. The port itself is actually never truly turned off. Really, do read the docs ;)
    – tlwhitec
    Sep 24 '13 at 10:01






  • 3




    I can confirm it works with kernels > 3.10. Just have to be sure that the device "id" you are using is correct : dmesg | grep "usb" and use the number after "usb", for example: usb 2-4.4: SerialNumber: A0848020 you will use: /sys/bus/usb/devices/2-4.4/power/.... Also, be sure that the device is not in use. I created a script to simplify this process
    – lepe
    Apr 27 '16 at 3:07


















up vote
21
down vote













I have found these solutions that at least work for properly configured Terminus FE 1.1 USB hub chip:



1.To turn off power on all USB ports of a hub, you may unbind the hub from kernel using:



echo "1-4.4.4" > /sys/bus/usb/drivers/usb/unbind


to turn power back on - you may bind it back using



echo "1-4.4.4" > /sys/bus/usb/drivers/usb/bind


2.Switching power at each port individually is trickier: I was able to use hubpower to control each port - but it comes with a downside: hubpower first disconnects the usbdevfs wich causes all of the USB devices to disconect from system, at least on ubuntu:



usb_ioctl.ioctl_code = USBDEVFS_DISCONNECT;
rc = ioctl(fd, USBDEVFS_IOCTL, &usb_ioctl);


With this ioctl disabled I was able to switch off individual port power without detaching all devices - but the power goes back on immediately (probably due to kernel seeing an uninitialized device) which causes USB device just to do a "cold restart" which is what I generally wanted to do. My patched hubpower is here






share|improve this answer





















  • The bind/unbind entries are confirmed to work on linux kernel 2.6.34, the ICH8 chipset, and Ubuntu 10.04.
    – user1357196
    Aug 22 '13 at 16:10








  • 4




    bind/unbind doesn't poweroff the USB port regardless the chipset. The device still gets power...
    – themihai
    Nov 8 '14 at 18:41










  • mouse laser is off, keyboard cant type, modem stops blinking - all good on my platform
    – eri
    Sep 19 '16 at 1:17


















up vote
17
down vote













PowerTOP from Intel allows you to toggle devices such as usb peripherals in real-time. These are called 'tunables'.



sudo apt install powertop
sudo powertop



  • Tab over to 'tunables'.

  • Scroll down to your device.

  • Hit enter to toggle power saving mode (Good/Bad)


enter image description here



Note that Bad means the device is always on. Toggling to Good will turn off the device after the preset inactive saving time (default is 2000ms).



See the PowerTOP docs for details on how to make these changes permanent.
It generates the config scripts for you (pretty much as described by other posters on this thread).



NOTE: These scripts do not affect USB pin power (which is always on).

These only send the driver protocol to activate and deactivate a device.


If you want to control pin power, you could use either a supported smart USB hub, or better yet a microcontroller.






share|improve this answer



















  • 2




    Awesome! :D I think this is the userfriendliest way to do it (although on low level it makes the same operations as outlined in the other answers.) Thank you, and may your answer reach the top ;)
    – Matyas
    May 9 '16 at 9:03






  • 1




    Thanks for your answer. Where do I have to start digging to change the preset inactive saving time?
    – mikezter
    Dec 21 '16 at 11:55










  • As mentioned by previous posters, kernel docs are here: kernel.org/doc/Documentation/usb/power-management.txt
    – Dominic Cerisano
    Mar 9 '17 at 21:17




















up vote
7
down vote













I wanted to do this, and with my USB hardware I couldn't. I wrote a hacky way how to do it here: http://pintant.cat/2012/05/12/power-off-usb-device/ . In short way: I used a USB relay to open/close the Vc of another USB cable...






share|improve this answer




























    up vote
    7
    down vote













    You could use uhubctl - command line utility to control USB power per port for compatible USB hubs.



    Disclosure - I am the author of uhubctl.






    share|improve this answer























    • fine tool on osx, but doesnt find any 'supported smart hub' on debian for me.
      – jitter
      Jan 7 at 23:13






    • 1




      On Linux, you need to either run it as root (under sudo), or to configure udev device permissions. It's also possible that your Linux host doesn't have compatible hubs connected.
      – mvp
      Jan 7 at 23:15










    • it's a 'beagle bone green' btw.
      – jitter
      Jan 11 at 1:55


















    up vote
    5
    down vote













    echo '2-1' |sudo tee /sys/bus/usb/drivers/usb/unbind


    works for ubuntu






    share|improve this answer























    • YOURS IS THE ONLY SOLUTION THAT WORKED ON MY CASE. I am using an acer make laptop 12.04LTS Ubuntu.
      – RicoRicochet
      Dec 12 '14 at 5:57










    • Doesn't poweroff the device, only removes it from the device list. How can I poweroff the USB port?
      – rustyx
      Dec 20 '14 at 15:11










    • This is also the only solution that worked for me for powering off a Wacom Intuos5 touch M tablet without unplugging it (on Fedora 28)
      – user1738984
      Sep 11 at 10:50


















    up vote
    2
    down vote













    USB 5v power is always on (even when the computer is turned off, on some computers and on some ports.) You will probably need to program an Arduino with some sort of switch, and control it via Serial library from USB plugged in to the computer.



    In other words, a combination of this switch tutorial and this tutorial on communicating via Serial libary to Arduino plugged in via USB.






    share|improve this answer




























      up vote
      0
      down vote













      I had a problem when connecting my android phone, I couldn't charge my phone because the power switch on and then off ...
      PowerTop let me find this setting and was useful to fix the issue ( auto value was causing issue):



      echo 'on' | sudo tee /sys/bus/usb/devices/1-1/power/control





      share|improve this answer





















        Your Answer






        StackExchange.ifUsing("editor", function () {
        StackExchange.using("externalEditor", function () {
        StackExchange.using("snippets", function () {
        StackExchange.snippets.init();
        });
        });
        }, "code-snippets");

        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "1"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














         

        draft saved


        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f4702216%2fcontrolling-a-usb-power-supply-on-off-with-linux%23new-answer', 'question_page');
        }
        );

        Post as a guest
































        9 Answers
        9






        active

        oldest

        votes








        9 Answers
        9






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        59
        down vote



        accepted










        Note. The information in this answer is relevant for the older kernels (up to 2.6.32). See tlwhitec's answer for the information on the newer kernels.



        # disable external wake-up; do this only once
        echo disabled > /sys/bus/usb/devices/usb1/power/wakeup

        echo on > /sys/bus/usb/devices/usb1/power/level # turn on
        echo suspend > /sys/bus/usb/devices/usb1/power/level # turn off


        (You may need to change usb1 to usb n)



        Source: Documentation/usb/power-management.txt.gz






        share|improve this answer



















        • 1




          Whoa, thanks for that. I was thinking I had to go through libUSB no matter what. Any idea how to get the names of the attached devices as well?
          – kamziro
          Jan 15 '11 at 21:56






        • 2




          @kamziro: try lsusb
          – Roman Cheplyaka
          Jan 15 '11 at 23:53






        • 7




          Doesn't work in Linux Ubuntu 2.6.32-26-generic
          – NoBugs
          Dec 31 '11 at 20:48






        • 5




          I'm getting permission denied error even if I use sudo!
          – Wally
          Jul 26 '14 at 7:52






        • 2




          same for me " permission denied" even after using sudo
          – Raulp
          Mar 4 '15 at 12:03















        up vote
        59
        down vote



        accepted










        Note. The information in this answer is relevant for the older kernels (up to 2.6.32). See tlwhitec's answer for the information on the newer kernels.



        # disable external wake-up; do this only once
        echo disabled > /sys/bus/usb/devices/usb1/power/wakeup

        echo on > /sys/bus/usb/devices/usb1/power/level # turn on
        echo suspend > /sys/bus/usb/devices/usb1/power/level # turn off


        (You may need to change usb1 to usb n)



        Source: Documentation/usb/power-management.txt.gz






        share|improve this answer



















        • 1




          Whoa, thanks for that. I was thinking I had to go through libUSB no matter what. Any idea how to get the names of the attached devices as well?
          – kamziro
          Jan 15 '11 at 21:56






        • 2




          @kamziro: try lsusb
          – Roman Cheplyaka
          Jan 15 '11 at 23:53






        • 7




          Doesn't work in Linux Ubuntu 2.6.32-26-generic
          – NoBugs
          Dec 31 '11 at 20:48






        • 5




          I'm getting permission denied error even if I use sudo!
          – Wally
          Jul 26 '14 at 7:52






        • 2




          same for me " permission denied" even after using sudo
          – Raulp
          Mar 4 '15 at 12:03













        up vote
        59
        down vote



        accepted







        up vote
        59
        down vote



        accepted






        Note. The information in this answer is relevant for the older kernels (up to 2.6.32). See tlwhitec's answer for the information on the newer kernels.



        # disable external wake-up; do this only once
        echo disabled > /sys/bus/usb/devices/usb1/power/wakeup

        echo on > /sys/bus/usb/devices/usb1/power/level # turn on
        echo suspend > /sys/bus/usb/devices/usb1/power/level # turn off


        (You may need to change usb1 to usb n)



        Source: Documentation/usb/power-management.txt.gz






        share|improve this answer














        Note. The information in this answer is relevant for the older kernels (up to 2.6.32). See tlwhitec's answer for the information on the newer kernels.



        # disable external wake-up; do this only once
        echo disabled > /sys/bus/usb/devices/usb1/power/wakeup

        echo on > /sys/bus/usb/devices/usb1/power/level # turn on
        echo suspend > /sys/bus/usb/devices/usb1/power/level # turn off


        (You may need to change usb1 to usb n)



        Source: Documentation/usb/power-management.txt.gz







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Dec 6 '17 at 14:08









        ItamarG3

        3,43861938




        3,43861938










        answered Jan 15 '11 at 21:42









        Roman Cheplyaka

        28.1k456101




        28.1k456101








        • 1




          Whoa, thanks for that. I was thinking I had to go through libUSB no matter what. Any idea how to get the names of the attached devices as well?
          – kamziro
          Jan 15 '11 at 21:56






        • 2




          @kamziro: try lsusb
          – Roman Cheplyaka
          Jan 15 '11 at 23:53






        • 7




          Doesn't work in Linux Ubuntu 2.6.32-26-generic
          – NoBugs
          Dec 31 '11 at 20:48






        • 5




          I'm getting permission denied error even if I use sudo!
          – Wally
          Jul 26 '14 at 7:52






        • 2




          same for me " permission denied" even after using sudo
          – Raulp
          Mar 4 '15 at 12:03














        • 1




          Whoa, thanks for that. I was thinking I had to go through libUSB no matter what. Any idea how to get the names of the attached devices as well?
          – kamziro
          Jan 15 '11 at 21:56






        • 2




          @kamziro: try lsusb
          – Roman Cheplyaka
          Jan 15 '11 at 23:53






        • 7




          Doesn't work in Linux Ubuntu 2.6.32-26-generic
          – NoBugs
          Dec 31 '11 at 20:48






        • 5




          I'm getting permission denied error even if I use sudo!
          – Wally
          Jul 26 '14 at 7:52






        • 2




          same for me " permission denied" even after using sudo
          – Raulp
          Mar 4 '15 at 12:03








        1




        1




        Whoa, thanks for that. I was thinking I had to go through libUSB no matter what. Any idea how to get the names of the attached devices as well?
        – kamziro
        Jan 15 '11 at 21:56




        Whoa, thanks for that. I was thinking I had to go through libUSB no matter what. Any idea how to get the names of the attached devices as well?
        – kamziro
        Jan 15 '11 at 21:56




        2




        2




        @kamziro: try lsusb
        – Roman Cheplyaka
        Jan 15 '11 at 23:53




        @kamziro: try lsusb
        – Roman Cheplyaka
        Jan 15 '11 at 23:53




        7




        7




        Doesn't work in Linux Ubuntu 2.6.32-26-generic
        – NoBugs
        Dec 31 '11 at 20:48




        Doesn't work in Linux Ubuntu 2.6.32-26-generic
        – NoBugs
        Dec 31 '11 at 20:48




        5




        5




        I'm getting permission denied error even if I use sudo!
        – Wally
        Jul 26 '14 at 7:52




        I'm getting permission denied error even if I use sudo!
        – Wally
        Jul 26 '14 at 7:52




        2




        2




        same for me " permission denied" even after using sudo
        – Raulp
        Mar 4 '15 at 12:03




        same for me " permission denied" even after using sudo
        – Raulp
        Mar 4 '15 at 12:03












        up vote
        53
        down vote













        According to the docs, there were several changes to the USB power management from kernels 2.6.32, which seem to settle in 2.6.38. Now you'll need to wait for the device to become idle, which is governed by the particular device driver. The driver needs to support it, otherwise the device will never reach this state. Unluckily, now the user has no chance to force this. However, if you're lucky and your device can become idle, then to turn this off you need to:



        echo "0" > "/sys/bus/usb/devices/usbX/power/autosuspend"
        echo "auto" > "/sys/bus/usb/devices/usbX/power/level"


        or, for kernels around 2.6.38 and above:



        echo "0" > "/sys/bus/usb/devices/usbX/power/autosuspend_delay_ms"
        echo "auto" > "/sys/bus/usb/devices/usbX/power/control"


        This literally means, go suspend at the moment the device becomes idle.



        So unless your fan is something "intelligent" that can be seen as a device and controlled by a driver, you probably won't have much luck on current kernels.






        share|improve this answer





















        • It seems this will cause the USB device to continuously get powered off...(?) How should power be resumed by me, after this worked? My goal is to restart the device once, not to permanently change its suspension configuration.
          – matanster
          Aug 16 '13 at 17:27








        • 3




          To resume a suspended device, you can disable again the "autosuspend" with echo "on" > "/sys/bus/usb/devices/usbX/power/control", but I think you need to understand the original purpose. The autosuspend feature is here merely to enable idling devices to enter a low-power state (where it might appear turned off), only to be resumed later when it's needed, either by the host or some external event. That happens (or should happen) automatically. The port itself is actually never truly turned off. Really, do read the docs ;)
          – tlwhitec
          Sep 24 '13 at 10:01






        • 3




          I can confirm it works with kernels > 3.10. Just have to be sure that the device "id" you are using is correct : dmesg | grep "usb" and use the number after "usb", for example: usb 2-4.4: SerialNumber: A0848020 you will use: /sys/bus/usb/devices/2-4.4/power/.... Also, be sure that the device is not in use. I created a script to simplify this process
          – lepe
          Apr 27 '16 at 3:07















        up vote
        53
        down vote













        According to the docs, there were several changes to the USB power management from kernels 2.6.32, which seem to settle in 2.6.38. Now you'll need to wait for the device to become idle, which is governed by the particular device driver. The driver needs to support it, otherwise the device will never reach this state. Unluckily, now the user has no chance to force this. However, if you're lucky and your device can become idle, then to turn this off you need to:



        echo "0" > "/sys/bus/usb/devices/usbX/power/autosuspend"
        echo "auto" > "/sys/bus/usb/devices/usbX/power/level"


        or, for kernels around 2.6.38 and above:



        echo "0" > "/sys/bus/usb/devices/usbX/power/autosuspend_delay_ms"
        echo "auto" > "/sys/bus/usb/devices/usbX/power/control"


        This literally means, go suspend at the moment the device becomes idle.



        So unless your fan is something "intelligent" that can be seen as a device and controlled by a driver, you probably won't have much luck on current kernels.






        share|improve this answer





















        • It seems this will cause the USB device to continuously get powered off...(?) How should power be resumed by me, after this worked? My goal is to restart the device once, not to permanently change its suspension configuration.
          – matanster
          Aug 16 '13 at 17:27








        • 3




          To resume a suspended device, you can disable again the "autosuspend" with echo "on" > "/sys/bus/usb/devices/usbX/power/control", but I think you need to understand the original purpose. The autosuspend feature is here merely to enable idling devices to enter a low-power state (where it might appear turned off), only to be resumed later when it's needed, either by the host or some external event. That happens (or should happen) automatically. The port itself is actually never truly turned off. Really, do read the docs ;)
          – tlwhitec
          Sep 24 '13 at 10:01






        • 3




          I can confirm it works with kernels > 3.10. Just have to be sure that the device "id" you are using is correct : dmesg | grep "usb" and use the number after "usb", for example: usb 2-4.4: SerialNumber: A0848020 you will use: /sys/bus/usb/devices/2-4.4/power/.... Also, be sure that the device is not in use. I created a script to simplify this process
          – lepe
          Apr 27 '16 at 3:07













        up vote
        53
        down vote










        up vote
        53
        down vote









        According to the docs, there were several changes to the USB power management from kernels 2.6.32, which seem to settle in 2.6.38. Now you'll need to wait for the device to become idle, which is governed by the particular device driver. The driver needs to support it, otherwise the device will never reach this state. Unluckily, now the user has no chance to force this. However, if you're lucky and your device can become idle, then to turn this off you need to:



        echo "0" > "/sys/bus/usb/devices/usbX/power/autosuspend"
        echo "auto" > "/sys/bus/usb/devices/usbX/power/level"


        or, for kernels around 2.6.38 and above:



        echo "0" > "/sys/bus/usb/devices/usbX/power/autosuspend_delay_ms"
        echo "auto" > "/sys/bus/usb/devices/usbX/power/control"


        This literally means, go suspend at the moment the device becomes idle.



        So unless your fan is something "intelligent" that can be seen as a device and controlled by a driver, you probably won't have much luck on current kernels.






        share|improve this answer












        According to the docs, there were several changes to the USB power management from kernels 2.6.32, which seem to settle in 2.6.38. Now you'll need to wait for the device to become idle, which is governed by the particular device driver. The driver needs to support it, otherwise the device will never reach this state. Unluckily, now the user has no chance to force this. However, if you're lucky and your device can become idle, then to turn this off you need to:



        echo "0" > "/sys/bus/usb/devices/usbX/power/autosuspend"
        echo "auto" > "/sys/bus/usb/devices/usbX/power/level"


        or, for kernels around 2.6.38 and above:



        echo "0" > "/sys/bus/usb/devices/usbX/power/autosuspend_delay_ms"
        echo "auto" > "/sys/bus/usb/devices/usbX/power/control"


        This literally means, go suspend at the moment the device becomes idle.



        So unless your fan is something "intelligent" that can be seen as a device and controlled by a driver, you probably won't have much luck on current kernels.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 1 '12 at 14:56









        tlwhitec

        886813




        886813












        • It seems this will cause the USB device to continuously get powered off...(?) How should power be resumed by me, after this worked? My goal is to restart the device once, not to permanently change its suspension configuration.
          – matanster
          Aug 16 '13 at 17:27








        • 3




          To resume a suspended device, you can disable again the "autosuspend" with echo "on" > "/sys/bus/usb/devices/usbX/power/control", but I think you need to understand the original purpose. The autosuspend feature is here merely to enable idling devices to enter a low-power state (where it might appear turned off), only to be resumed later when it's needed, either by the host or some external event. That happens (or should happen) automatically. The port itself is actually never truly turned off. Really, do read the docs ;)
          – tlwhitec
          Sep 24 '13 at 10:01






        • 3




          I can confirm it works with kernels > 3.10. Just have to be sure that the device "id" you are using is correct : dmesg | grep "usb" and use the number after "usb", for example: usb 2-4.4: SerialNumber: A0848020 you will use: /sys/bus/usb/devices/2-4.4/power/.... Also, be sure that the device is not in use. I created a script to simplify this process
          – lepe
          Apr 27 '16 at 3:07


















        • It seems this will cause the USB device to continuously get powered off...(?) How should power be resumed by me, after this worked? My goal is to restart the device once, not to permanently change its suspension configuration.
          – matanster
          Aug 16 '13 at 17:27








        • 3




          To resume a suspended device, you can disable again the "autosuspend" with echo "on" > "/sys/bus/usb/devices/usbX/power/control", but I think you need to understand the original purpose. The autosuspend feature is here merely to enable idling devices to enter a low-power state (where it might appear turned off), only to be resumed later when it's needed, either by the host or some external event. That happens (or should happen) automatically. The port itself is actually never truly turned off. Really, do read the docs ;)
          – tlwhitec
          Sep 24 '13 at 10:01






        • 3




          I can confirm it works with kernels > 3.10. Just have to be sure that the device "id" you are using is correct : dmesg | grep "usb" and use the number after "usb", for example: usb 2-4.4: SerialNumber: A0848020 you will use: /sys/bus/usb/devices/2-4.4/power/.... Also, be sure that the device is not in use. I created a script to simplify this process
          – lepe
          Apr 27 '16 at 3:07
















        It seems this will cause the USB device to continuously get powered off...(?) How should power be resumed by me, after this worked? My goal is to restart the device once, not to permanently change its suspension configuration.
        – matanster
        Aug 16 '13 at 17:27






        It seems this will cause the USB device to continuously get powered off...(?) How should power be resumed by me, after this worked? My goal is to restart the device once, not to permanently change its suspension configuration.
        – matanster
        Aug 16 '13 at 17:27






        3




        3




        To resume a suspended device, you can disable again the "autosuspend" with echo "on" > "/sys/bus/usb/devices/usbX/power/control", but I think you need to understand the original purpose. The autosuspend feature is here merely to enable idling devices to enter a low-power state (where it might appear turned off), only to be resumed later when it's needed, either by the host or some external event. That happens (or should happen) automatically. The port itself is actually never truly turned off. Really, do read the docs ;)
        – tlwhitec
        Sep 24 '13 at 10:01




        To resume a suspended device, you can disable again the "autosuspend" with echo "on" > "/sys/bus/usb/devices/usbX/power/control", but I think you need to understand the original purpose. The autosuspend feature is here merely to enable idling devices to enter a low-power state (where it might appear turned off), only to be resumed later when it's needed, either by the host or some external event. That happens (or should happen) automatically. The port itself is actually never truly turned off. Really, do read the docs ;)
        – tlwhitec
        Sep 24 '13 at 10:01




        3




        3




        I can confirm it works with kernels > 3.10. Just have to be sure that the device "id" you are using is correct : dmesg | grep "usb" and use the number after "usb", for example: usb 2-4.4: SerialNumber: A0848020 you will use: /sys/bus/usb/devices/2-4.4/power/.... Also, be sure that the device is not in use. I created a script to simplify this process
        – lepe
        Apr 27 '16 at 3:07




        I can confirm it works with kernels > 3.10. Just have to be sure that the device "id" you are using is correct : dmesg | grep "usb" and use the number after "usb", for example: usb 2-4.4: SerialNumber: A0848020 you will use: /sys/bus/usb/devices/2-4.4/power/.... Also, be sure that the device is not in use. I created a script to simplify this process
        – lepe
        Apr 27 '16 at 3:07










        up vote
        21
        down vote













        I have found these solutions that at least work for properly configured Terminus FE 1.1 USB hub chip:



        1.To turn off power on all USB ports of a hub, you may unbind the hub from kernel using:



        echo "1-4.4.4" > /sys/bus/usb/drivers/usb/unbind


        to turn power back on - you may bind it back using



        echo "1-4.4.4" > /sys/bus/usb/drivers/usb/bind


        2.Switching power at each port individually is trickier: I was able to use hubpower to control each port - but it comes with a downside: hubpower first disconnects the usbdevfs wich causes all of the USB devices to disconect from system, at least on ubuntu:



        usb_ioctl.ioctl_code = USBDEVFS_DISCONNECT;
        rc = ioctl(fd, USBDEVFS_IOCTL, &usb_ioctl);


        With this ioctl disabled I was able to switch off individual port power without detaching all devices - but the power goes back on immediately (probably due to kernel seeing an uninitialized device) which causes USB device just to do a "cold restart" which is what I generally wanted to do. My patched hubpower is here






        share|improve this answer





















        • The bind/unbind entries are confirmed to work on linux kernel 2.6.34, the ICH8 chipset, and Ubuntu 10.04.
          – user1357196
          Aug 22 '13 at 16:10








        • 4




          bind/unbind doesn't poweroff the USB port regardless the chipset. The device still gets power...
          – themihai
          Nov 8 '14 at 18:41










        • mouse laser is off, keyboard cant type, modem stops blinking - all good on my platform
          – eri
          Sep 19 '16 at 1:17















        up vote
        21
        down vote













        I have found these solutions that at least work for properly configured Terminus FE 1.1 USB hub chip:



        1.To turn off power on all USB ports of a hub, you may unbind the hub from kernel using:



        echo "1-4.4.4" > /sys/bus/usb/drivers/usb/unbind


        to turn power back on - you may bind it back using



        echo "1-4.4.4" > /sys/bus/usb/drivers/usb/bind


        2.Switching power at each port individually is trickier: I was able to use hubpower to control each port - but it comes with a downside: hubpower first disconnects the usbdevfs wich causes all of the USB devices to disconect from system, at least on ubuntu:



        usb_ioctl.ioctl_code = USBDEVFS_DISCONNECT;
        rc = ioctl(fd, USBDEVFS_IOCTL, &usb_ioctl);


        With this ioctl disabled I was able to switch off individual port power without detaching all devices - but the power goes back on immediately (probably due to kernel seeing an uninitialized device) which causes USB device just to do a "cold restart" which is what I generally wanted to do. My patched hubpower is here






        share|improve this answer





















        • The bind/unbind entries are confirmed to work on linux kernel 2.6.34, the ICH8 chipset, and Ubuntu 10.04.
          – user1357196
          Aug 22 '13 at 16:10








        • 4




          bind/unbind doesn't poweroff the USB port regardless the chipset. The device still gets power...
          – themihai
          Nov 8 '14 at 18:41










        • mouse laser is off, keyboard cant type, modem stops blinking - all good on my platform
          – eri
          Sep 19 '16 at 1:17













        up vote
        21
        down vote










        up vote
        21
        down vote









        I have found these solutions that at least work for properly configured Terminus FE 1.1 USB hub chip:



        1.To turn off power on all USB ports of a hub, you may unbind the hub from kernel using:



        echo "1-4.4.4" > /sys/bus/usb/drivers/usb/unbind


        to turn power back on - you may bind it back using



        echo "1-4.4.4" > /sys/bus/usb/drivers/usb/bind


        2.Switching power at each port individually is trickier: I was able to use hubpower to control each port - but it comes with a downside: hubpower first disconnects the usbdevfs wich causes all of the USB devices to disconect from system, at least on ubuntu:



        usb_ioctl.ioctl_code = USBDEVFS_DISCONNECT;
        rc = ioctl(fd, USBDEVFS_IOCTL, &usb_ioctl);


        With this ioctl disabled I was able to switch off individual port power without detaching all devices - but the power goes back on immediately (probably due to kernel seeing an uninitialized device) which causes USB device just to do a "cold restart" which is what I generally wanted to do. My patched hubpower is here






        share|improve this answer












        I have found these solutions that at least work for properly configured Terminus FE 1.1 USB hub chip:



        1.To turn off power on all USB ports of a hub, you may unbind the hub from kernel using:



        echo "1-4.4.4" > /sys/bus/usb/drivers/usb/unbind


        to turn power back on - you may bind it back using



        echo "1-4.4.4" > /sys/bus/usb/drivers/usb/bind


        2.Switching power at each port individually is trickier: I was able to use hubpower to control each port - but it comes with a downside: hubpower first disconnects the usbdevfs wich causes all of the USB devices to disconect from system, at least on ubuntu:



        usb_ioctl.ioctl_code = USBDEVFS_DISCONNECT;
        rc = ioctl(fd, USBDEVFS_IOCTL, &usb_ioctl);


        With this ioctl disabled I was able to switch off individual port power without detaching all devices - but the power goes back on immediately (probably due to kernel seeing an uninitialized device) which causes USB device just to do a "cold restart" which is what I generally wanted to do. My patched hubpower is here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Aug 7 '13 at 8:12









        grandrew

        402410




        402410












        • The bind/unbind entries are confirmed to work on linux kernel 2.6.34, the ICH8 chipset, and Ubuntu 10.04.
          – user1357196
          Aug 22 '13 at 16:10








        • 4




          bind/unbind doesn't poweroff the USB port regardless the chipset. The device still gets power...
          – themihai
          Nov 8 '14 at 18:41










        • mouse laser is off, keyboard cant type, modem stops blinking - all good on my platform
          – eri
          Sep 19 '16 at 1:17


















        • The bind/unbind entries are confirmed to work on linux kernel 2.6.34, the ICH8 chipset, and Ubuntu 10.04.
          – user1357196
          Aug 22 '13 at 16:10








        • 4




          bind/unbind doesn't poweroff the USB port regardless the chipset. The device still gets power...
          – themihai
          Nov 8 '14 at 18:41










        • mouse laser is off, keyboard cant type, modem stops blinking - all good on my platform
          – eri
          Sep 19 '16 at 1:17
















        The bind/unbind entries are confirmed to work on linux kernel 2.6.34, the ICH8 chipset, and Ubuntu 10.04.
        – user1357196
        Aug 22 '13 at 16:10






        The bind/unbind entries are confirmed to work on linux kernel 2.6.34, the ICH8 chipset, and Ubuntu 10.04.
        – user1357196
        Aug 22 '13 at 16:10






        4




        4




        bind/unbind doesn't poweroff the USB port regardless the chipset. The device still gets power...
        – themihai
        Nov 8 '14 at 18:41




        bind/unbind doesn't poweroff the USB port regardless the chipset. The device still gets power...
        – themihai
        Nov 8 '14 at 18:41












        mouse laser is off, keyboard cant type, modem stops blinking - all good on my platform
        – eri
        Sep 19 '16 at 1:17




        mouse laser is off, keyboard cant type, modem stops blinking - all good on my platform
        – eri
        Sep 19 '16 at 1:17










        up vote
        17
        down vote













        PowerTOP from Intel allows you to toggle devices such as usb peripherals in real-time. These are called 'tunables'.



        sudo apt install powertop
        sudo powertop



        • Tab over to 'tunables'.

        • Scroll down to your device.

        • Hit enter to toggle power saving mode (Good/Bad)


        enter image description here



        Note that Bad means the device is always on. Toggling to Good will turn off the device after the preset inactive saving time (default is 2000ms).



        See the PowerTOP docs for details on how to make these changes permanent.
        It generates the config scripts for you (pretty much as described by other posters on this thread).



        NOTE: These scripts do not affect USB pin power (which is always on).

        These only send the driver protocol to activate and deactivate a device.


        If you want to control pin power, you could use either a supported smart USB hub, or better yet a microcontroller.






        share|improve this answer



















        • 2




          Awesome! :D I think this is the userfriendliest way to do it (although on low level it makes the same operations as outlined in the other answers.) Thank you, and may your answer reach the top ;)
          – Matyas
          May 9 '16 at 9:03






        • 1




          Thanks for your answer. Where do I have to start digging to change the preset inactive saving time?
          – mikezter
          Dec 21 '16 at 11:55










        • As mentioned by previous posters, kernel docs are here: kernel.org/doc/Documentation/usb/power-management.txt
          – Dominic Cerisano
          Mar 9 '17 at 21:17

















        up vote
        17
        down vote













        PowerTOP from Intel allows you to toggle devices such as usb peripherals in real-time. These are called 'tunables'.



        sudo apt install powertop
        sudo powertop



        • Tab over to 'tunables'.

        • Scroll down to your device.

        • Hit enter to toggle power saving mode (Good/Bad)


        enter image description here



        Note that Bad means the device is always on. Toggling to Good will turn off the device after the preset inactive saving time (default is 2000ms).



        See the PowerTOP docs for details on how to make these changes permanent.
        It generates the config scripts for you (pretty much as described by other posters on this thread).



        NOTE: These scripts do not affect USB pin power (which is always on).

        These only send the driver protocol to activate and deactivate a device.


        If you want to control pin power, you could use either a supported smart USB hub, or better yet a microcontroller.






        share|improve this answer



















        • 2




          Awesome! :D I think this is the userfriendliest way to do it (although on low level it makes the same operations as outlined in the other answers.) Thank you, and may your answer reach the top ;)
          – Matyas
          May 9 '16 at 9:03






        • 1




          Thanks for your answer. Where do I have to start digging to change the preset inactive saving time?
          – mikezter
          Dec 21 '16 at 11:55










        • As mentioned by previous posters, kernel docs are here: kernel.org/doc/Documentation/usb/power-management.txt
          – Dominic Cerisano
          Mar 9 '17 at 21:17















        up vote
        17
        down vote










        up vote
        17
        down vote









        PowerTOP from Intel allows you to toggle devices such as usb peripherals in real-time. These are called 'tunables'.



        sudo apt install powertop
        sudo powertop



        • Tab over to 'tunables'.

        • Scroll down to your device.

        • Hit enter to toggle power saving mode (Good/Bad)


        enter image description here



        Note that Bad means the device is always on. Toggling to Good will turn off the device after the preset inactive saving time (default is 2000ms).



        See the PowerTOP docs for details on how to make these changes permanent.
        It generates the config scripts for you (pretty much as described by other posters on this thread).



        NOTE: These scripts do not affect USB pin power (which is always on).

        These only send the driver protocol to activate and deactivate a device.


        If you want to control pin power, you could use either a supported smart USB hub, or better yet a microcontroller.






        share|improve this answer














        PowerTOP from Intel allows you to toggle devices such as usb peripherals in real-time. These are called 'tunables'.



        sudo apt install powertop
        sudo powertop



        • Tab over to 'tunables'.

        • Scroll down to your device.

        • Hit enter to toggle power saving mode (Good/Bad)


        enter image description here



        Note that Bad means the device is always on. Toggling to Good will turn off the device after the preset inactive saving time (default is 2000ms).



        See the PowerTOP docs for details on how to make these changes permanent.
        It generates the config scripts for you (pretty much as described by other posters on this thread).



        NOTE: These scripts do not affect USB pin power (which is always on).

        These only send the driver protocol to activate and deactivate a device.


        If you want to control pin power, you could use either a supported smart USB hub, or better yet a microcontroller.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jun 27 '17 at 22:41

























        answered May 6 '16 at 5:54









        Dominic Cerisano

        1,3811731




        1,3811731








        • 2




          Awesome! :D I think this is the userfriendliest way to do it (although on low level it makes the same operations as outlined in the other answers.) Thank you, and may your answer reach the top ;)
          – Matyas
          May 9 '16 at 9:03






        • 1




          Thanks for your answer. Where do I have to start digging to change the preset inactive saving time?
          – mikezter
          Dec 21 '16 at 11:55










        • As mentioned by previous posters, kernel docs are here: kernel.org/doc/Documentation/usb/power-management.txt
          – Dominic Cerisano
          Mar 9 '17 at 21:17
















        • 2




          Awesome! :D I think this is the userfriendliest way to do it (although on low level it makes the same operations as outlined in the other answers.) Thank you, and may your answer reach the top ;)
          – Matyas
          May 9 '16 at 9:03






        • 1




          Thanks for your answer. Where do I have to start digging to change the preset inactive saving time?
          – mikezter
          Dec 21 '16 at 11:55










        • As mentioned by previous posters, kernel docs are here: kernel.org/doc/Documentation/usb/power-management.txt
          – Dominic Cerisano
          Mar 9 '17 at 21:17










        2




        2




        Awesome! :D I think this is the userfriendliest way to do it (although on low level it makes the same operations as outlined in the other answers.) Thank you, and may your answer reach the top ;)
        – Matyas
        May 9 '16 at 9:03




        Awesome! :D I think this is the userfriendliest way to do it (although on low level it makes the same operations as outlined in the other answers.) Thank you, and may your answer reach the top ;)
        – Matyas
        May 9 '16 at 9:03




        1




        1




        Thanks for your answer. Where do I have to start digging to change the preset inactive saving time?
        – mikezter
        Dec 21 '16 at 11:55




        Thanks for your answer. Where do I have to start digging to change the preset inactive saving time?
        – mikezter
        Dec 21 '16 at 11:55












        As mentioned by previous posters, kernel docs are here: kernel.org/doc/Documentation/usb/power-management.txt
        – Dominic Cerisano
        Mar 9 '17 at 21:17






        As mentioned by previous posters, kernel docs are here: kernel.org/doc/Documentation/usb/power-management.txt
        – Dominic Cerisano
        Mar 9 '17 at 21:17












        up vote
        7
        down vote













        I wanted to do this, and with my USB hardware I couldn't. I wrote a hacky way how to do it here: http://pintant.cat/2012/05/12/power-off-usb-device/ . In short way: I used a USB relay to open/close the Vc of another USB cable...






        share|improve this answer

























          up vote
          7
          down vote













          I wanted to do this, and with my USB hardware I couldn't. I wrote a hacky way how to do it here: http://pintant.cat/2012/05/12/power-off-usb-device/ . In short way: I used a USB relay to open/close the Vc of another USB cable...






          share|improve this answer























            up vote
            7
            down vote










            up vote
            7
            down vote









            I wanted to do this, and with my USB hardware I couldn't. I wrote a hacky way how to do it here: http://pintant.cat/2012/05/12/power-off-usb-device/ . In short way: I used a USB relay to open/close the Vc of another USB cable...






            share|improve this answer












            I wanted to do this, and with my USB hardware I couldn't. I wrote a hacky way how to do it here: http://pintant.cat/2012/05/12/power-off-usb-device/ . In short way: I used a USB relay to open/close the Vc of another USB cable...







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered May 20 '12 at 10:25









            Carles

            10111




            10111






















                up vote
                7
                down vote













                You could use uhubctl - command line utility to control USB power per port for compatible USB hubs.



                Disclosure - I am the author of uhubctl.






                share|improve this answer























                • fine tool on osx, but doesnt find any 'supported smart hub' on debian for me.
                  – jitter
                  Jan 7 at 23:13






                • 1




                  On Linux, you need to either run it as root (under sudo), or to configure udev device permissions. It's also possible that your Linux host doesn't have compatible hubs connected.
                  – mvp
                  Jan 7 at 23:15










                • it's a 'beagle bone green' btw.
                  – jitter
                  Jan 11 at 1:55















                up vote
                7
                down vote













                You could use uhubctl - command line utility to control USB power per port for compatible USB hubs.



                Disclosure - I am the author of uhubctl.






                share|improve this answer























                • fine tool on osx, but doesnt find any 'supported smart hub' on debian for me.
                  – jitter
                  Jan 7 at 23:13






                • 1




                  On Linux, you need to either run it as root (under sudo), or to configure udev device permissions. It's also possible that your Linux host doesn't have compatible hubs connected.
                  – mvp
                  Jan 7 at 23:15










                • it's a 'beagle bone green' btw.
                  – jitter
                  Jan 11 at 1:55













                up vote
                7
                down vote










                up vote
                7
                down vote









                You could use uhubctl - command line utility to control USB power per port for compatible USB hubs.



                Disclosure - I am the author of uhubctl.






                share|improve this answer














                You could use uhubctl - command line utility to control USB power per port for compatible USB hubs.



                Disclosure - I am the author of uhubctl.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited May 20 at 3:58

























                answered Nov 8 '16 at 20:00









                mvp

                69.9k885122




                69.9k885122












                • fine tool on osx, but doesnt find any 'supported smart hub' on debian for me.
                  – jitter
                  Jan 7 at 23:13






                • 1




                  On Linux, you need to either run it as root (under sudo), or to configure udev device permissions. It's also possible that your Linux host doesn't have compatible hubs connected.
                  – mvp
                  Jan 7 at 23:15










                • it's a 'beagle bone green' btw.
                  – jitter
                  Jan 11 at 1:55


















                • fine tool on osx, but doesnt find any 'supported smart hub' on debian for me.
                  – jitter
                  Jan 7 at 23:13






                • 1




                  On Linux, you need to either run it as root (under sudo), or to configure udev device permissions. It's also possible that your Linux host doesn't have compatible hubs connected.
                  – mvp
                  Jan 7 at 23:15










                • it's a 'beagle bone green' btw.
                  – jitter
                  Jan 11 at 1:55
















                fine tool on osx, but doesnt find any 'supported smart hub' on debian for me.
                – jitter
                Jan 7 at 23:13




                fine tool on osx, but doesnt find any 'supported smart hub' on debian for me.
                – jitter
                Jan 7 at 23:13




                1




                1




                On Linux, you need to either run it as root (under sudo), or to configure udev device permissions. It's also possible that your Linux host doesn't have compatible hubs connected.
                – mvp
                Jan 7 at 23:15




                On Linux, you need to either run it as root (under sudo), or to configure udev device permissions. It's also possible that your Linux host doesn't have compatible hubs connected.
                – mvp
                Jan 7 at 23:15












                it's a 'beagle bone green' btw.
                – jitter
                Jan 11 at 1:55




                it's a 'beagle bone green' btw.
                – jitter
                Jan 11 at 1:55










                up vote
                5
                down vote













                echo '2-1' |sudo tee /sys/bus/usb/drivers/usb/unbind


                works for ubuntu






                share|improve this answer























                • YOURS IS THE ONLY SOLUTION THAT WORKED ON MY CASE. I am using an acer make laptop 12.04LTS Ubuntu.
                  – RicoRicochet
                  Dec 12 '14 at 5:57










                • Doesn't poweroff the device, only removes it from the device list. How can I poweroff the USB port?
                  – rustyx
                  Dec 20 '14 at 15:11










                • This is also the only solution that worked for me for powering off a Wacom Intuos5 touch M tablet without unplugging it (on Fedora 28)
                  – user1738984
                  Sep 11 at 10:50















                up vote
                5
                down vote













                echo '2-1' |sudo tee /sys/bus/usb/drivers/usb/unbind


                works for ubuntu






                share|improve this answer























                • YOURS IS THE ONLY SOLUTION THAT WORKED ON MY CASE. I am using an acer make laptop 12.04LTS Ubuntu.
                  – RicoRicochet
                  Dec 12 '14 at 5:57










                • Doesn't poweroff the device, only removes it from the device list. How can I poweroff the USB port?
                  – rustyx
                  Dec 20 '14 at 15:11










                • This is also the only solution that worked for me for powering off a Wacom Intuos5 touch M tablet without unplugging it (on Fedora 28)
                  – user1738984
                  Sep 11 at 10:50













                up vote
                5
                down vote










                up vote
                5
                down vote









                echo '2-1' |sudo tee /sys/bus/usb/drivers/usb/unbind


                works for ubuntu






                share|improve this answer














                echo '2-1' |sudo tee /sys/bus/usb/drivers/usb/unbind


                works for ubuntu







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Apr 12 '14 at 17:05









                mustaccio

                14k83637




                14k83637










                answered Apr 12 '14 at 16:46









                user3527264

                5111




                5111












                • YOURS IS THE ONLY SOLUTION THAT WORKED ON MY CASE. I am using an acer make laptop 12.04LTS Ubuntu.
                  – RicoRicochet
                  Dec 12 '14 at 5:57










                • Doesn't poweroff the device, only removes it from the device list. How can I poweroff the USB port?
                  – rustyx
                  Dec 20 '14 at 15:11










                • This is also the only solution that worked for me for powering off a Wacom Intuos5 touch M tablet without unplugging it (on Fedora 28)
                  – user1738984
                  Sep 11 at 10:50


















                • YOURS IS THE ONLY SOLUTION THAT WORKED ON MY CASE. I am using an acer make laptop 12.04LTS Ubuntu.
                  – RicoRicochet
                  Dec 12 '14 at 5:57










                • Doesn't poweroff the device, only removes it from the device list. How can I poweroff the USB port?
                  – rustyx
                  Dec 20 '14 at 15:11










                • This is also the only solution that worked for me for powering off a Wacom Intuos5 touch M tablet without unplugging it (on Fedora 28)
                  – user1738984
                  Sep 11 at 10:50
















                YOURS IS THE ONLY SOLUTION THAT WORKED ON MY CASE. I am using an acer make laptop 12.04LTS Ubuntu.
                – RicoRicochet
                Dec 12 '14 at 5:57




                YOURS IS THE ONLY SOLUTION THAT WORKED ON MY CASE. I am using an acer make laptop 12.04LTS Ubuntu.
                – RicoRicochet
                Dec 12 '14 at 5:57












                Doesn't poweroff the device, only removes it from the device list. How can I poweroff the USB port?
                – rustyx
                Dec 20 '14 at 15:11




                Doesn't poweroff the device, only removes it from the device list. How can I poweroff the USB port?
                – rustyx
                Dec 20 '14 at 15:11












                This is also the only solution that worked for me for powering off a Wacom Intuos5 touch M tablet without unplugging it (on Fedora 28)
                – user1738984
                Sep 11 at 10:50




                This is also the only solution that worked for me for powering off a Wacom Intuos5 touch M tablet without unplugging it (on Fedora 28)
                – user1738984
                Sep 11 at 10:50










                up vote
                2
                down vote













                USB 5v power is always on (even when the computer is turned off, on some computers and on some ports.) You will probably need to program an Arduino with some sort of switch, and control it via Serial library from USB plugged in to the computer.



                In other words, a combination of this switch tutorial and this tutorial on communicating via Serial libary to Arduino plugged in via USB.






                share|improve this answer

























                  up vote
                  2
                  down vote













                  USB 5v power is always on (even when the computer is turned off, on some computers and on some ports.) You will probably need to program an Arduino with some sort of switch, and control it via Serial library from USB plugged in to the computer.



                  In other words, a combination of this switch tutorial and this tutorial on communicating via Serial libary to Arduino plugged in via USB.






                  share|improve this answer























                    up vote
                    2
                    down vote










                    up vote
                    2
                    down vote









                    USB 5v power is always on (even when the computer is turned off, on some computers and on some ports.) You will probably need to program an Arduino with some sort of switch, and control it via Serial library from USB plugged in to the computer.



                    In other words, a combination of this switch tutorial and this tutorial on communicating via Serial libary to Arduino plugged in via USB.






                    share|improve this answer












                    USB 5v power is always on (even when the computer is turned off, on some computers and on some ports.) You will probably need to program an Arduino with some sort of switch, and control it via Serial library from USB plugged in to the computer.



                    In other words, a combination of this switch tutorial and this tutorial on communicating via Serial libary to Arduino plugged in via USB.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 24 '16 at 2:55









                    NoBugs

                    5,346857111




                    5,346857111






















                        up vote
                        0
                        down vote













                        I had a problem when connecting my android phone, I couldn't charge my phone because the power switch on and then off ...
                        PowerTop let me find this setting and was useful to fix the issue ( auto value was causing issue):



                        echo 'on' | sudo tee /sys/bus/usb/devices/1-1/power/control





                        share|improve this answer

























                          up vote
                          0
                          down vote













                          I had a problem when connecting my android phone, I couldn't charge my phone because the power switch on and then off ...
                          PowerTop let me find this setting and was useful to fix the issue ( auto value was causing issue):



                          echo 'on' | sudo tee /sys/bus/usb/devices/1-1/power/control





                          share|improve this answer























                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            I had a problem when connecting my android phone, I couldn't charge my phone because the power switch on and then off ...
                            PowerTop let me find this setting and was useful to fix the issue ( auto value was causing issue):



                            echo 'on' | sudo tee /sys/bus/usb/devices/1-1/power/control





                            share|improve this answer












                            I had a problem when connecting my android phone, I couldn't charge my phone because the power switch on and then off ...
                            PowerTop let me find this setting and was useful to fix the issue ( auto value was causing issue):



                            echo 'on' | sudo tee /sys/bus/usb/devices/1-1/power/control






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jul 17 '17 at 8:51









                            WonderLand

                            3,19733759




                            3,19733759






























                                 

                                draft saved


                                draft discarded



















































                                 


                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f4702216%2fcontrolling-a-usb-power-supply-on-off-with-linux%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest




















































































                                Popular posts from this blog

                                Bressuire

                                Vorschmack

                                Quarantine