Grabbing Serials and MAC Addresses

During various automations in Mac OS X it helps to grab some key unique identifiers for machines. Two very common identifiers are the serial number of a computer and the MAC Address. To grab a systems serial number I usually use ioreg to run the following, which simply outputs a systems serial number:

ioreg -l | grep IOPlatformSerialNumber | cut -c 37-46

Because a system can have multiple MAC addresses (one per unique adapter), I will also use ioreg to grab those:

ioreg -l | grep IOMACAddress

Or to just see an output of the first in the list (en0):

ioreg -l -w 0 | grep IOMACAddress | cut -c 37-48 | head -n 1

3 Comments

  • May 12, 2010 - 2:13 pm | Permalink

    Beware of the new 17 inch MacBook Pros, they have an extra character in the serial.

  • Pingback: One More Character In Serials | Krypted

  • nate
    May 13, 2010 - 11:23 am | Permalink

    why not use something like this instead?

    system_profiler SPHardwareDataType | awk ‘/Serial/ {print $4}’

    or if you have puppet installed, you can use facter to grab all of those details.

  • Comments are closed.