Seu código deve ser
for i in /sys/bus/usb/devices/*/power/level; do sudo echo on > $i; done
OR
for i in /sys/bus/usb/devices/*/power/level; do sudo sh -c "echo on > $i"; done
Eu tentei lsusb
e posso ver meu mouse na lista.
Eu tentei
for foo in /sys/bus/usb/devices/*/power/level;
> do echo on > $foo;
> done
Mas recebi esta resposta
bash: /sys/bus/usb/devices/1-4/power/level: Permission denied
bash: /sys/bus/usb/devices/2-2/power/level: Permission denied
bash: /sys/bus/usb/devices/5-1/power/level: Permission denied
bash: /sys/bus/usb/devices/5-3/power/level: Permission denied
bash: /sys/bus/usb/devices/usb1/power/level: Permission denied
bash: /sys/bus/usb/devices/usb2/power/level: Permission denied
bash: /sys/bus/usb/devices/usb3/power/level: Permission denied
bash: /sys/bus/usb/devices/usb4/power/level: Permission denied
bash: /sys/bus/usb/devices/usb5/power/level: Permission denied
bash: /sys/bus/usb/devices/usb6/power/level: Permission denied
Observe que isso só acontece sempre que meu laptop é desconectado.
Seu código deve ser
for i in /sys/bus/usb/devices/*/power/level; do sudo echo on > $i; done
OR
for i in /sys/bus/usb/devices/*/power/level; do sudo sh -c "echo on > $i"; done