MacOS – How to Poll USB mouse through terminal in El Capitan

bashmacosterminalusb

I've been trying to view which devices are connected to my USB ports through terminal in El Capitan, in particular a USB mouse. I've read online that I can ls /dev/tty.* to view all connected devices. But each time I try this before and after connecting a device, the output does not change.

I've also tried ls /dev and do not see a change in the output.

I've also tried ls /dev >> before.txt, then, after plugging in a device (like a mouse), ls /dev >> after.txt', then vimdiff before.txt after.txt. And I still do not see any new devices.

Is this the correct location to be looking in for devices? (namely /dev)

If not, where should I be looking?

Note, there is not a location for /dev/input on my machine. Also, I'm doing this because I would like to practice reading the bits from a serial bus and I need access to the bits incoming from the USB port.

Best Answer

For any regular USB device, use:

diskutil list

This brings up the disk utility command line interface's "list" tool, which provides you with information on internal and connected disks, be it through USB, SATA or PCIe. It's much simpler than looking through /dev (which includes ttys and a lot of other stuff), and gives you much more information like capacity, partition tabling and the S.M.A.R.T. status (if supported) of your drive.

If you'd like to look through /dev though, try

ls /dev | grep disk

This will show only the entries with "disk" in them (disks and connected devices in OS X are mounted as /dev/disk[number]).