Tutoriel Linux

USB ports under Linux: commands that actually show what’s plugged in

Débutant5 min de lecture
À retenirLinux n'est pas réservé aux experts. Le bon point de départ : une distribution accessible, une sauvegarde propre et quelques commandes comprises.

When a USB drive, external hard drive, or serial adapter stops responding under Linux, the first thing to do is not to restart the machine. You should first check if the device is recognized by the kernel, by the USB bus, and then by the system.

For that, a few commands are all it takes: lsusb, lsusb -t, dmesg And journalctl -kThey don’t all tell the same story. If you use them in the right order, you can quickly save time on an unrecognized device.

Start by listing the USB devices

The simplest command is lsusbIt displays the devices detected on the USB buses:

lsusb

You get lines like this:

Bus 002 Device 003: ID 0781:5581 SanDisk Corp. Ultra
Bus 001 Device 004: ID 046d:c52b Logitech, Inc. Unifying Receiver

The important part is often the identifier. vendor:product, For example 0781:5581Even if Linux has not loaded the correct driver or has not mounted the disk, this identifier already proves that the device is responding on the USB bus.

If the command does not exist, install the package usbutils :

sudo apt update
sudo apt install usbutils

On other distributions, the package name often remains usbutilsThe manual page lsusb(8) details the useful options.

View the directory tree with lsusb -t

lsusb tells you what is detected. lsusb -t shows you how trendy it is:

lsusb -t

This view is very useful with USB hubs, docking stations, and front-panel ports. Example:

/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/4p, 5000M
    |__ Port 2: Dev 3, If 0, Class=Mass Storage, Driver=usb-storage, 5000M

Here, we see a USB storage device in 5000M, therefore using USB 3.x. If a fast drive appears in 480MIt may be connected to a USB 2.0 port, via a limited cable, or behind a hub that limits the speed.

Also look at the column DriverIf it is empty or unexpected, the device is seen, but the driver is not necessarily loaded as expected.

Monitor what is happening at the connection point

To properly diagnose the problem, open a terminal, start kernel monitoring, and then plug in the device:

sudo dmesg -w

You can also use journalctl If your distribution centralizes logs using systemd:

sudo journalctl -k -f

At the connection point, you should see lines that refer to usb, new high-speed USB device, usb-storage, ttyUSB Or sdX depending on the equipment. It’s often more telling than lsusb alone, because the errors appear at the exact moment of connection.

To reread the latest messages without staying in real-time updates:

sudo dmesg | tail -80
sudo journalctl -k -n 80 --no-pager

If you want to delve deeper into reading the logs at startup or after an incident, I’ve detailed the method in the guide on… journalctl and the logs of the last Linux boot.

Identifying a USB drive that won’t mount

A USB drive may be detected but not automatically mounted. In this case, check the storage blocks:

lsblk -o NAME,SIZE,FSTYPE,LABEL,MOUNTPOINTS,MODEL
sudo blkid

If the disc appears in lsblkThe problem isn’t the USB port. You need to check the file system, permissions, automounting, or partition errors. If nothing appears in lsblk, return to the kernel logs.

On a suspect USB drive or disk, avoid immediately attempting a repair. First, read the messages:

Lines with reset high-speed USB device, I/O error Or device descriptor read They point more towards an unstable cable, box, power supply or peripheral.

Identify a serial, network, or Bluetooth adapter

For a USB to serial adapter, look for the peripherals ttyUSB Or ttyACM :

ls -l /dev/ttyUSB* /dev/ttyACM* 2>/dev/null
sudo dmesg | grep -Ei 'ttyUSB|ttyACM|ch341|cp210|ftdi'

For a USB network adapter, combine lsusb with network interfaces:

ip link
nmcli device status 2>/dev/null

If the adapter is seen by lsusb but not in ip linkYou are probably dealing with a driver or firmware issue. In this case, note the exact USB identifier before searching for a solution. Search 0bda:8153 Linux is much more effective than simply searching for “USB ethernet adapter”.

The quick fix when a USB device is unresponsive

When I need to diagnose quickly, I use this sequence:

lsusb
lsusb -t
sudo journalctl -k -f

Next, I unplug and replug the device. If there’s no change in the logs, I test a different port, cable, or power supply. If the logs show activity but the device is still unusable, I check the driver and storage. lsblk, or the interface created in /dev.

It’s not a magic bullet, but it avoids going off in all directions. First the USB bus, then the kernel logs, and only then the mounting, the driver, or the application that needs to use the hardware.

This needs to be verified before concluding that the port is dead.

Before blaming the USB port, at a minimum test:

  • another cable, especially for external drives and smartphones;
  • a port directly on the machine, without a hub;
  • another device on the same port;
  • the messages dmesg Or journalctl -k at the time of connection;
  • the power supply of the device if it is a 2.5-inch drive, an enclosure or a docking station.

If lsusb If the device is detected on one port but not another, you already have a hardware lead. If no port detects it, test it on another machine before modifying your Linux configuration.

For commands related to logs, the references dmesg(1) And journalctl(1) remain useful when you want to check a specific option.

sudo apt update && sudo apt upgrade