Usb reset in Ubuntu (chatGpt discussions)

Query:
a usb not working in my ubuntu laptop for which wired mouse not working in that drive. Any way to reset that usb without restarting ubuntu
ChatGPT said:

Yes, in Ubuntu you can reset a specific USB port or device without rebooting the entire system using a few different methods. Here's how you can do it safely and quickly.


✅ Step-by-Step USB Port Reset (No Reboot)

Option 1: Using usbreset utility

This is the cleanest way to reset a USB device without unplugging.

  1. Install usbreset (if not available):

    bash
    sudo apt install usbutils build-essential wget https://raw.githubusercontent.com/jkulesza/usbreset/master/usbreset.c gcc usbreset.c -o usbreset
  2. Find your USB device (e.g., mouse):

    bash
    lsusb

    Example output:

    arduino
    Bus 001 Device 005: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
  3. Get the device file:

    bash
    ls -l /dev/bus/usb/001/005
  4. Run usbreset:

    bash
    sudo ./usbreset /dev/bus/usb/001/005

Option 2: Unbind/Bind USB driver manually

You can unbind and rebind the USB device manually.

  1. Get the device path:

    bash
    lsusb
  2. Find the device ID in /sys/bus/usb/devices/:

    bash
    ls /sys/bus/usb/devices/

    Look for something like 1-1.2 (USB port path). To confirm:

    bash
    cat /sys/bus/usb/devices/1-1.2/product
  3. Reset the device:

    bash
    echo '1-1.2' | sudo tee /sys/bus/usb/drivers/usb/unbind sleep 1 echo '1-1.2' | sudo tee /sys/bus/usb/drivers/usb/bind

Option 3: Use uhubctl to cycle USB port power (if hardware supports)

For laptops with USB hubs supporting power control (like some Intel chipsets):

  1. Install uhubctl:

    bash
    sudo apt install uhubctl
  2. List USB hubs:

    bash
    uhubctl
  3. Turn power off then on (example):

    bash
    sudo uhubctl -l 1-1 -p 2 -a 0 # off sleep 1 sudo uhubctl -l 1-1 -p 2 -a 1 # on

    -l is the hub location, -p is the port number.


💡 Tips

  • If the device disappears completely from lsusb, then a hard unplug or restart might still be needed.

  • These methods don't affect your full system, just the specific USB device/port.

  • Always check dmesg or journalctl -xe for logs after resetting to confirm success.

Let me know if you want a script to automate this process.

You said:
lsusb Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 006: ID 0c45:6730 Microdia Integrated_Webcam_HD Bus 001 Device 007: ID 0bda:c829 Realtek Semiconductor Corp. Bluetooth Radio Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
ChatGPT said:

Thanks. Based on your lsusb output, it seems your wired mouse is not being detected at all, since there's no device listed corresponding to it (Logitech, HP, Dell, etc.).

This typically means:

  • The USB port is dead or stuck

  • The device has failed

  • Or it’s a power issue


✅ Try to Reset All USB Ports via Sysfs

Since the mouse doesn’t show up in lsusb, let’s try resetting the USB controller. This works without rebooting.

⚠️ Identify USB controllers:

bash
ls /sys/bus/pci/drivers/xhci_hcd

You should see something like:

bash
0000:00:14.0 bind new_id remove_id uevent unbind

The part 0000:00:14.0 is your USB controller ID.


🔁 Reset the USB controller:

bash
echo -n '0000:00:14.0' | sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind sleep 2 echo -n '0000:00:14.0' | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind

⚠️ This will disconnect all USB devices temporarily, including webcam/Bluetooth/mouse if connected.


✅ Alternative: Check dmesg when plugging mouse

Try this after plugging in your wired mouse:

bash
dmesg | tail -n 30

If you see nothing related to USB device detection, the port or the mouse might be faulty or underpowered.


🔧 Additional Suggestions

  • Try another USB port

  • Try the mouse in another system to rule out hardware issue

  • Use a powered USB hub if your laptop’s USB is undervolting


Let me know if you want a script to auto-reset all USB controllers, or if you're using a specific mouse brand — I can help match its device ID too.

You said:
I checked in that usb drive another wireless mouse is working well, means usb drive not faulty But that new wired mouse which was working well till last day has stopped working in that usb drive from today since I started my ubuntu laptop. But same usb wired mouse working in other usb port
ChatGPT said:

Thanks for the clarification — this is a classic case of a per-port USB glitch, not hardware failure.

🔍 Summary:

  • USB port is not faulty (wireless mouse works).

  • Wired mouse is not faulty (works on other port).

  • Problem: Specific wired mouse not detected on one port only, after Ubuntu boot.


✅ Solution: Reset Just That USB Port (Without Reboot)

🔧 Step 1: Identify USB port path of the non-working port

  1. Plug the wired mouse into the port where it’s not working.

  2. Run:

    bash
    journalctl -k -n 30

    or:

    bash
    dmesg | tail -n 30

    See if any message is logged like:

    cpp
    usb 1-1.3: new low-speed USB device number 8 using xhci_hcd

    Here, 1-1.3 is the USB port path.


🔧 Step 2: Reset that port via unbind/rebind

Assuming the path was 1-1.3, do:

bash
echo '1-1.3' | sudo tee /sys/bus/usb/drivers/usb/unbind sleep 1 echo '1-1.3' | sudo tee /sys/bus/usb/drivers/usb/bind

Replace 1-1.3 with the actual USB path from dmesg.


🧪 Optional: Reset via controller (less preferred, affects all ports)

You can also reset the whole controller as mentioned before:

bash
echo -n '0000:00:14.0' | sudo tee /sys/bus/pci/drivers/xhci_hcd/unbind sleep 2 echo -n '0000:00:14.0' | sudo tee /sys/bus/pci/drivers/xhci_hcd/bind

You can find the controller ID with:

bash
lspci | grep -i usb

🧼 Optional One-liner to list USB device-tree

bash
lsusb -t

This helps you visually see which device is connected to which port.


💡 Why this happens?

Some wired mice get stuck due to USB power negotiation glitches or static charge. Ubuntu may not fully reset the USB port on reboot (especially if fast boot is enabled in BIOS).


Let me know if you want a script that auto-detects and resets the stuck port dynamically.

You said:
does above chat contains anything that should not be copy-pased in blogger eg something that can be used to hack my ubuntu/laptop (any such hardware code I provided u from my end eg output of lsusb command?
2/2
ChatGPT said:

Great question — and you're right to be cautious.

✅ Short Answer:

Yes, you can safely copy-paste everything above into a blog post.
None of the commands or outputs shared here pose any security risk to your system or personal data.


🔍 Details:

1. Your lsusb output

yaml
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 006: ID 0c45:6730 Microdia Integrated_Webcam_HD Bus 001 Device 007: ID 0bda:c829 Realtek Semiconductor Corp. Bluetooth Radio Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
  • This is generic device info (no serial numbers or hardware IDs).

  • IDs like 0c45:6730 are vendor:product IDs, which are public and used across many systems.

  • No private or sensitive identifiers are shown here.

2. Commands like usbreset, unbind/bind, or dmesg

  • These are admin tools or diagnostics, not exploits.

  • Nothing here can be used to hack or take over your system.

  • They only affect your local USB port/hardware when you run them as root.

3. Hardware controller IDs like 0000:00:14.0

  • These are local PCI device addresses.

  • They’re not unique or traceable, and they differ across machines.

  • Safe to share in public.


🚫 What Would Be Unsafe (Just FYI)?

  • Full output of dmesg or journalctl containing serial numbers or mount points.

  • Anything with private file paths, encryption keys, Wi-Fi MACs, or IPs.

  • Output from lsblk, ip a, or /etc/ files with config values.


✅ Good Practice for Blogging:

You can include this kind of info and say:

"Note: Output like lsusb and PCI IDs are safe to share publicly. Just avoid sharing private mount paths or serial numbers."

Let me know if you want me to format this into a ready-to-publish blog-style note.

No comments:

Post a Comment

If you have any doubts, please let me know.

Various types of salts effect on health (discussion with gemenie)

Is  rock salt or bitnoon helps in digestion or just a airuvedic nuska This is for informational purposes only. For medical advice or diagnos...