DEV Community

Jacopo Valanzano
Jacopo Valanzano

Posted on • Updated on

🐧 Linux - Nifty Shell Commands #1

Disconnect and reconnect a USB device, with Linux kernel:

On my device, i have 4 USB ports, and they are all listed in
/sys/bus/usb/drivers/usb
as 1-1 1-1.3 1-1.4 and 2-1 respectively.

$ ls /sys/bus/usb/drivers/usb

Inspect dmesg to analyse each USB device
$ dmesg

Let's say the USB 1-1.3 needs to be reconnected:

$ echo 1-1.3 > /sys/bus/usb/drivers/usb/unbind

Wait, give some time to both the device and the kernel

$ sleep 5

Reconnect the USB drive

$ echo 1-1.3 > /sys/bus/usb/drivers/usb/bind

Discussion (0)