Get serial numbers of connected USB devices

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