How to find USB device in Linux


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.

KONICA MINOLTA DIGITAL CAMERA

You can use different methods to get this like using udevinfo command, from sysfs, from /var/log/messages.

Using udevinfo:

for DEV in /dev/sd*; do
udevinfo -q env -n $DEV 2>/dev/null | grep "ID_BUS=usb";
done

Using sysfs:

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

Using /var/log/messages:

Grep the usb device in /var/log/messages file, when usb device is connected.

I hope USB device can be detected easily now.

About these ads

One thought on “How to find USB device in Linux

  1. Pingback: Linux console - programmatical detection of which device a USB storage is assigned to - Just just easy answers

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s