我试过了lsusb
,我可以在列表中看到我的鼠标。
我试过
for foo in /sys/bus/usb/devices/*/power/level;
> do echo on > $foo;
> done
但我收到了这个回复
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
请注意,只有当我的笔记本电脑拔下电源时才会发生这种情况。
答案1
你的代码应该是,
for i in /sys/bus/usb/devices/*/power/level; do sudo echo on > $i; done
或者
for i in /sys/bus/usb/devices/*/power/level; do sudo sh -c "echo on > $i"; done