# Best way to find a USB fob's serial number?

## afabbro

What's the best way to find a USB fob's serial number?  I'm looking for something I can put in a script.

Diffing dmesg doesn't work because the serial doesn't always show up there.

udevinfo will sometimes show multiple serial numbers.

When I'm try to do is say "run this script, insert your fob, press enter, and wah-lah, here is the fob's serial number".

Ideas?

----------

## Headrush

Are you looking to use the serial number with udev or hal rules? If so, I find using the Vender ID and Product ID found with lsusb much easier.

Is the serial number attribute not listed when you do something like this:

```
udevinfo -a -p /sys/block/hda
```

or

```
 hdparm -I /dev/hda
```

Of course change to match your HD device node location.

----------

## afabbro

 *Headrush wrote:*   

> Are you looking to use the serial number with udev or hal rules? If so, I find using the Vender ID and Product ID found with lsusb much easier.
> 
> Is the serial number attribute not listed when you do something like this:
> 
> ```
> ...

 

I think we have a winner!  Thank you...I was looking all over /proc and forgot about udevinfo.

----------

## afabbro

 *afabbro wrote:*   

>  *Headrush wrote:*   Are you looking to use the serial number with udev or hal rules? If so, I find using the Vender ID and Product ID found with lsusb much easier.
> 
> Is the serial number attribute not listed when you do something like this:
> 
> ```
> ...

 

Er, maybe not...some devices show a serial for both the onboard hub and the device:

```
   

    # udevinfo -a -p /sys/block/sde | grep -i serial

    SYSFS{serial}=="85a5b1f2c96492"

    SYSFS{serial}=="0000:00:1d.7"

```

...and others show no serial at all...this Corsair fob, for instance, just shows a serial for the onboard controller...I'm looking for a serial to make udev rules:

```

# udevinfo -a -p /sys/block/sde

udevinfo starts with the device the node belongs to and then walks up the

device chain, to print for every device found, all possibly useful attributes

in the udev key format.

Only attributes within one device section may be used together in one rule,

to match the device for which the node will be created.

  looking at device '/block/sde':

    KERNEL=="sde"

    SUBSYSTEM=="block"

    SYSFS{stat}=="      10       10      160       48        0        0        0        0        0       48       48"

    SYSFS{size}=="2031616"

    SYSFS{removable}=="1"

    SYSFS{range}=="16"

    SYSFS{dev}=="8:64"

  looking at device '/devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5.1/1-5.1:1.0/host23/target23:0:0/23:0:0:0':

    ID=="23:0:0:0"

    BUS=="scsi"

    DRIVER=="sd"

    SYSFS{ioerr_cnt}=="0x1"

    SYSFS{iodone_cnt}=="0x14"

    SYSFS{iorequest_cnt}=="0x14"

    SYSFS{iocounterbits}=="32"

    SYSFS{timeout}=="30"

    SYSFS{state}=="running"

    SYSFS{rev}=="1.00"

    SYSFS{model}=="Flash Voyager  "

    SYSFS{vendor}=="Corsair "

    SYSFS{scsi_level}=="3"

    SYSFS{type}=="0"

    SYSFS{queue_type}=="none"

    SYSFS{queue_depth}=="1"

    SYSFS{device_blocked}=="0"

    SYSFS{max_sectors}=="240"

  looking at device '/devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5.1/1-5.1:1.0/host23/target23:0:0':

    ID=="target23:0:0"

    BUS==""

    DRIVER==""

  looking at device '/devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5.1/1-5.1:1.0/host23':

    ID=="host23"

    BUS==""

    DRIVER==""

  looking at device '/devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5.1/1-5.1:1.0':

    ID=="1-5.1:1.0"

    BUS=="usb"

    DRIVER=="usb-storage"

    SYSFS{modalias}=="usb:v067Bp2517d0100dc00dsc00dp00ic08isc05ip50"

    SYSFS{bInterfaceProtocol}=="50"

    SYSFS{bInterfaceSubClass}=="05"

    SYSFS{bInterfaceClass}=="08"

    SYSFS{bNumEndpoints}=="02"

    SYSFS{bAlternateSetting}==" 0"

    SYSFS{bInterfaceNumber}=="00"

  looking at device '/devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5.1':

    ID=="1-5.1"

    BUS=="usb"

    DRIVER=="usb"

    SYSFS{configuration}==""

    SYSFS{product}=="USB Mass Storage Device"

    SYSFS{manufacturer}=="Prolific Technology Inc."

    SYSFS{maxchild}=="0"

    SYSFS{version}==" 2.00"

    SYSFS{devnum}=="48"

    SYSFS{speed}=="480"

    SYSFS{bMaxPacketSize0}=="64"

    SYSFS{bNumConfigurations}=="1"

    SYSFS{bDeviceProtocol}=="00"

    SYSFS{bDeviceSubClass}=="00"

    SYSFS{bDeviceClass}=="00"

    SYSFS{bcdDevice}=="0100"

    SYSFS{idProduct}=="2517"

    SYSFS{idVendor}=="067b"

    SYSFS{bMaxPower}=="  2mA"

    SYSFS{bmAttributes}=="c0"

    SYSFS{bConfigurationValue}=="1"

    SYSFS{bNumInterfaces}==" 1"

  looking at device '/devices/pci0000:00/0000:00:1d.7/usb1/1-5':

    ID=="1-5"

    BUS=="usb"

    DRIVER=="usb"

    SYSFS{configuration}==""

    SYSFS{product}=="USB Embedded Hub"

    SYSFS{manufacturer}=="Prolific Technology Inc."

    SYSFS{maxchild}=="1"

    SYSFS{version}==" 2.00"

    SYSFS{devnum}=="47"

    SYSFS{speed}=="480"

    SYSFS{bMaxPacketSize0}=="64"

    SYSFS{bNumConfigurations}=="1"

    SYSFS{bDeviceProtocol}=="01"

    SYSFS{bDeviceSubClass}=="00"

    SYSFS{bDeviceClass}=="09"

    SYSFS{bcdDevice}=="0100"

    SYSFS{idProduct}=="2515"

    SYSFS{idVendor}=="067b"

    SYSFS{bMaxPower}=="100mA"

    SYSFS{bmAttributes}=="c0"

    SYSFS{bConfigurationValue}=="1"

    SYSFS{bNumInterfaces}==" 1"

  looking at device '/devices/pci0000:00/0000:00:1d.7/usb1':

    ID=="usb1"

    BUS=="usb"

    DRIVER=="usb"

    SYSFS{configuration}==""

    SYSFS{serial}=="0000:00:1d.7"

    SYSFS{product}=="EHCI Host Controller"

    SYSFS{manufacturer}=="Linux 2.6.14.2y ehci_hcd"

    SYSFS{maxchild}=="8"

    SYSFS{version}==" 2.00"

    SYSFS{devnum}=="1"

    SYSFS{speed}=="480"

    SYSFS{bMaxPacketSize0}=="8"

    SYSFS{bNumConfigurations}=="1"

    SYSFS{bDeviceProtocol}=="01"

    SYSFS{bDeviceSubClass}=="00"

    SYSFS{bDeviceClass}=="09"

    SYSFS{bcdDevice}=="0206"

    SYSFS{idProduct}=="0000"

    SYSFS{idVendor}=="0000"

    SYSFS{bMaxPower}=="  0mA"

    SYSFS{bmAttributes}=="e0"

    SYSFS{bConfigurationValue}=="1"

    SYSFS{bNumInterfaces}==" 1"

  looking at device '/devices/pci0000:00/0000:00:1d.7':

    ID=="0000:00:1d.7"

    BUS=="pci"

    DRIVER=="ehci_hcd"

    SYSFS{modalias}=="pci:v00008086d000024DDsv00008086sd00004246bc0Csc03i20"

    SYSFS{local_cpus}=="3"

    SYSFS{irq}=="19"

    SYSFS{class}=="0x0c0320"

    SYSFS{subsystem_device}=="0x4246"

    SYSFS{subsystem_vendor}=="0x8086"

    SYSFS{device}=="0x24dd"

    SYSFS{vendor}=="0x8086"

  looking at device '/devices/pci0000:00':

    ID=="pci0000:00"

    BUS==""

    DRIVER==""

```

----------

