I wondered when I had to find the USB device name in Linux using shell script (shell command), it was little tricky, specially in case of UDEV.
You can use different methods to get this like using udevinfo command, from sysfs, from /var/log/messages.
for DEV in /dev/sd*; do
udevinfo -q env -n $DEV 2>/dev/null | grep "ID_BUS=usb";
Change this according to your need.
find /sys/bus/usb/drivers/usb-storage/[1-9]-[0-1]\:1.0/|grep -wo sd\[a-z]|head -1
Grep the usb device in /var/log/messages file, when usb device is connected.
I hope USB device can be detected easily now.
One thought on “How to find USB device in Linux”
Pingback: Linux console - programmatical detection of which device a USB storage is assigned to - Just just easy answers