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.
Get serial numbers of connected USB devices
command lineterminalusb
Best Answer
Information about USB Devices is stored differently under Linux then macOS:
In Linux,
usb-devices
is abash
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:
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.
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:Same device under macOS using
system_profiler SPUSBDataType
:Output under macOS using
system_profiler SPUSBDataType | grep "Serial Number" -B5
: