Linux – a Linux command that lists only USB storage devices

command linelinuxscsiusb

I would like to list only the USB storage devices connected to my computer. Since these are SCSI disks, I used the command lsscsi, which lists the USB drives as well as my computer's hard drive and CD drive. Is there a way to ignore the memory storage that's not a USB? I have also tried lsusb, but this includes my keyboard, mouse, and other non-storage devices.

Best Answer

This answer checks the list of all attached block devices and iterates over them with udevadmin to check their respective ID_BUS.

You can see all attached block devices in /sys/block. Here is the bash script from the linked answer that should let you know if it is a USB storage device:

for device in /sys/block/*
do
    if udevadm info --query=property --path=$device | grep -q ^ID_BUS=usb
    then
        echo $device
    fi
done
Related Question