6

I'm searching for a terminal command to find out the serial numbers of connected USB devices on macOS computers. Is there any equivalent to the linux command "usb-devices"? I tried "ioreg -p IOUSB" but the output does not contain the serial numbers.

8

Information about USB Devices is stored differently under Linux then macOS:

  • In Linux, usb-devices is a bash script that essentially reads a bunch of text files, symlinked to /sys/bus/usb/devices/usb*, that contain information about the USB Devices and formats it in the output you see under Linux.

  • In macOS, it does not have such a script as it doesn't store the information in the same manner. However, if you want to output information about USB Devices that are enumerated by the OS, in Terminal, then use the following command:

    system_profiler SPUSBDataType
    

    If a USB Device has a serial number it will be shown in the output.


As mentioned by Allan in his comment, you can use the following command to minimize the output to include relevant portions of the device information that contain the device name and serial number with a bit of additional info.

system_profiler SPUSBDataType | grep "Serial Number" -B5

Note that doing this does obscure some of the device information as compared to the info outputted by usb-devices, although it may be unnecessary info depending on your needs.


As an example, here is the usb-devices output, in Linux, for an 8 GB USB Flash Drive:

T:  Bus=03 Lev=02 Prnt=03 Port=00 Cnt=01 Dev#=  6 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=0781 ProdID=5530 Rev=01.26
S:  Manufacturer=SanDisk
S:  Product=Cruzer
S:  SerialNumber=20042214412B1A33690E
C:  #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=200mA
I:  If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage

Same device under macOS using system_profiler SPUSBDataType:

            Cruzer:

              Product ID: 0x5530
              Vendor ID: 0x0781  (SanDisk Corporation)
              Version: 1.26
              Serial Number: 20042214412B1A33690E
              Speed: Up to 480 Mb/sec
              Manufacturer: SanDisk
              Location ID: 0x1d110000 / 7
              Current Available (mA): 500
              Current Required (mA): 200
              Capacity: 8 GB (8,004,304,896 bytes)
              Removable Media: Yes
              Detachable Drive: Yes
              BSD Name: disk3
              Partition Map Type: MBR (Master Boot Record)
              S.M.A.R.T. status: Not Supported
              Volumes:
                disk3s1:
                  Capacity: 2.97 GB (2,966,634,496 bytes)
                  BSD Name: disk3s1
                  Content: 0x17
                NO NAME:
                  Capacity: 110.1 MB (110,100,480 bytes)
                  Available: 4.1 MB (4,124,672 bytes)
                  Writable: Yes
                  File System: MS-DOS FAT16
                  BSD Name: disk3s2
                  Mount Point: /Volumes/NO NAME
                  Content: DOS_FAT_12
                disk3s3:
                  Capacity: 3.92 GB (3,923,232,768 bytes)
                  BSD Name: disk3s3
                  Content: Linux

Output under macOS using system_profiler SPUSBDataType | grep "Serial Number" -B5:

            Cruzer:

              Product ID: 0x5530
              Vendor ID: 0x0781  (SanDisk Corporation)
              Version: 1.26
              Serial Number: 20042214412B1A33690E
  • 3
    If you just want the serial numbers, append | grep "Serial Number" -B5 to the command above to get the device and the serial number associated with it. – Allan Mar 6 '17 at 14:15
  • This is exactly what i needed. Thank you. But, is this command also supported by older macOS versions? – Phelps Mar 6 '17 at 18:31
  • 1
    @Phelps, Yes both commands shown in the answer are supported in earlier versions of OS X/macOS. – user3439894 Mar 6 '17 at 19:01
0

by the way: I found that, if you connect an external hard drive or SSD using an external enclosure or USB to SATA adapter cable, if you use these terminal commands or System Information, you'll see the Serial Number, Product ID etc of the Adapter cable or enclosure itself (probably of the controller chip inside), not the desired SN for the Hard drive or SSD etc. For example, this picture appears in my Mac Mini > system information when I attached a 250GB Samsung Evo SSD, the info provided corresponds to the The adapter cable, which identifies with a Product ID of 0x0621 and a Vendor ID of 0x1f75 (Innostor Co, Ltd.) which is related to Startech, which is the brand name in Amazon for this USB adapter cable.
enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .