How do I list all storage devices (thumb drives/external hard drives) that are connected via USB, from the command line?

Solution 1:

If you are looking for the mounted disks, a simple

df

will list them along with all your other disks along with some useful info.

Solution 2:

I'd recommend checking the udev properties of the devices, specifically the ID_BUS property:

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