Summer Sale 2026 – NPI EA (cat = Baeldung on Linux)
announcement - icon

Yes, we're now running our only Summer Sale. All Courses are 30% off until 20th July, 2026:

>> EXPLORE ACCESS NOW

Baeldung Pro – Linux – NPI EA (cat = Baeldung on Linux)
announcement - icon

Learn through the super-clean Baeldung Pro experience:

>> Membership and Baeldung Pro.

No ads, dark-mode and 6 months free of IntelliJ Idea Ultimate to start with.

1. Introduction

Resetting a USB device from the command line interface can be crucial for system administrators and developers. This is especially true for USB devices connected to remote servers or when systems fail to respond or malfunction. Further, knowing how to reset a USB device can save us a lot of time and effort while troubleshooting a problematic USB device, managing multiple devices, or looking to refresh a connection.

In this tutorial, we’ll explore how to identify and reset a USB device from the CLI on Linux. Additionally, we’ll cover different approaches, including using the usbreset, sysfs, and udevadm Linux tools.

2. Understanding USB Device Issues

USB devices are ubiquitous and include everything from keyboards and mice to external storage, printers, and even cameras.

While these devices are generally reliable, scenarios such as power surges, driver issues, and communication failures can lead to malfunction or unresponsiveness.

However, instead of restarting the whole system or physically disconnecting the device, a more efficient way is to reset the USB device through the CLI.

Before exploring how to reset a USB device, let’s briefly look at how USB devices are structured in Linux. When a USB device is connected, Linux registers it under the /dev directory and assigns it a device file. For example, the /dev/sda file can associate with a USB storage device.

Furthermore, device files also exist under the /sys/bus/usb/devices/ directory. The device tree under the /sys/bus/usb/devices/ path contains information about all USB buses and devices connected to the system. Each USB device receives a unique identifier in the format of bus-port.device. For example, 1-1.1 can represent a device connected to bus 1, port 1, and device 1.

3. Identifying the USB Device

Before resetting the USB device, we need to identify it. Several tools can help us with this, including lsusb, dmesg, and usb-devices.

3.1. Using lsusb

The lsusb command lists all USB devices connected to the system. It provides details such as the device ID, manufacturer, and bus number:

$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 06cb:00d8 Synaptics, Inc. 
Bus 001 Device 002: ID 04f2:b669 Chicony Electronics Co., Ltd HP HD Camera
Bus 001 Device 004: ID 0bda:b00c Realtek Semiconductor Corp. Bluetooth Radio
...

The Bus and Device numbers are important because they help us locate the device in the /sys directory. For example, in the output above, the Realtek Semiconductor Corp. Bluetooth Radio device is on bus 001, device 004.

3.2. Using dmseg

The dmesg command shows kernel messages, including logs related to USB-connected devices. After plugging in a USB device, we can filter the output of the dmesg command to see what the system logs about that device:

$ dmesg | grep usb
[    4.661154] usb 1-2: new high-speed USB device number 2 using xhci_hcd
[    4.834508] usb 1-2: New USB device found, idVendor=04f2, idProduct=b669, bcdDevice=96.60
[    4.834526] usb 1-2: New USB device strings: Mfr=3, Product=1, SerialNumber=2
[    4.834533] usb 1-2: Product: HP HD Camera
...

In this case, we see that the USB device was connected to bus 1-2 and is recognized as an HP HD Camera.

3.3. Using usb-devices

Another useful command is usb-devices, which provides detailed information about all USB devices on the system.

We can use it to get more verbose data about a device, including its product ID, vendor ID, and the driver in use:

$ usb-devices
T:  Bus=01 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#=  2 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=04f2 ProdID=b669 Rev=96.60
S:  Manufacturer=Chicony Electronics Co.,Ltd.
S:  Product=HP HD Camera
S:  SerialNumber=0001
C:  #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=500mA
I:  If#=0x0 Alt= 0 #EPs= 1 Cls=0e(video) Sub=01 Prot=00 Driver=uvcvideo
I:  If#=0x1 Alt= 0 #EPs= 0 Cls=0e(video) Sub=02 Prot=00 Driver=uvcvideo
...

Once we identify the USB device, we can proceed to reset it.

4. Using usbreset Command

The usbreset tool is a simple utility that enables users to reset USB devices from the command line. It can be particularly useful for troubleshooting issues with USB devices that are unresponsive or malfunctioning without the need to physically unplug and replug the device.

The usbreset command may not be installed by default on all Linux distros but can often be found in the usbutils package, or we can compile it from source.

Let’s look at the basic syntax of the using the usbreset command:

$ usbreset /dev/bus/usb/<bus>/<device>

Once we identify the device using any of the methods in the section above, we can use the usbreset command with the appropriate bus and device numbers:

$ sudo ./usbreset /dev/bus/usb/001/002

After we run this command, the device should reset, which is similar to unplugging and replugging it.

5. Using sysfs

Another way to reset a USB device is by using the sysfs interface. The Linux kernel exposes USB devices through the /sys/bus/usb/devices/ directory, which enables users to interact with hardware components like USB devices through pseudo-files.

To reset a USB device, we need to first navigate to the corresponding directory for the device. We can use the bus and device numbers from the lsusb command to identify the correct path:

$ ls /sys/bus/usb/devices/
1-0:1.0  1-10  1-10:1.0  1-10:1.1  1-2  1-2:1.0  1-2:1.1  1-7  1-7:1.0  2-0:1.0  usb1  usb2n

Once the device path is identified, we can reset it by first deauthorizing (disconnecting) the device from the system:

$ echo 0 | sudo tee /sys/bus/usb/devices/1-2/authorized

When the value 0 is written to the authorized file, the kernel unbinds the USB device, effectively disconnecting it from the system.

Next, we can reauthorize the device:

$ echo 1 | sudo tee /sys/bus/usb/devices/1-2/authorized

Writing 1 back to the authorized file reauthorizes the device, which is similar to physically reconnecting it. This causes the kernel to reinitialize the device, usually assigning the same bus and device number as before.

6. Using udevadm

Alternatively, we can use the udevadm tool to manage device events and trigger a reset. While it’s not as direct as the other methods, it’s a reliable way to interact with hardware devices.

Similar to the other methods, the first step is identifying the device information using a command like lsusb. Then, we can trigger the reset:

$ sudo udevadm trigger --action=add /sys/bus/usb/devices/1-2

Running this command should reinitialize the device, effectively resetting it.

7. Conclusion

In this article, we’ve looked at how to use tools such as usbreset, sysfs, and udevadm to reset USB devices. Each method provides an efficient way to handle malfunctioning USB devices without rebooting the system or physically unplugging the device.

Resetting a USB device from the CLI can be a powerful tool for system administrators or developers, especially when working with remote systems.

By following the steps outlined in this article, we should be able to quickly and safely reset USB devices and get them back in working order.