# How can I turn off the power of a USB port?

## crocket

I have a USB microphone that I want to remain turned off most of the time.

Can linux turn a USB port on and off?

----------

## fedeliallalinea

You can try with

```
# echo 0 > /sys/bus/usb/devices/7-1/power/autosuspend_delay_ms

# echo auto > /sys/bus/usb/devices/7-1/power/control

# echo 7-1 > /sys/bus/usb/drivers/usb/unbind
```

how 7-1 is <bus>.<port>.<port> then you can check with lsusb -t (also with dmesg usb-storage 7-1:1.0: USB Mass Storage device detected)

----------

## crocket

 *fedeliallalinea wrote:*   

> You can try with
> 
> ```
> # echo 0 > /sys/bus/usb/devices/7-1/power/autosuspend_delay_ms
> 
> ...

 

I figured out that a USB hub must support per-port power switching. My desktop computer's internal USB hubs don't support it. Raspberry Pi 3 B+ supports per-port power switching in all its USB ports.

I can use uhubctl to turn on and off USB ports.

----------

