Does anybody know a terminal command that gives me the model of my Mac?

For example - "MacBook Pro, Retina, 13-inch, Mid 2013" or "MacBook Pro, Late 2009" or "Mac Mini, Early 2010".

That information does not exist in the SystemProfiler (/usr/sbin/system_profiler SPHardwareDataType), but in OS X 10.7 and OS X 10.8 you can see that information when you click "More Info..." in the "About This Mac" window.

  • 1
    I don't think there exists a command to identify a Mac as "Late 2009" directly. However it can be derived from the Model Identifier, see my answer for an explanation. What do you mean by the But in OS X 10.7 and 10.8... sentence? When I look in the About This Mac window I don't see anything that states Late 2009 or something similar. – Saaru Lindestøkke Aug 6 '13 at 10:11
  • 2
    @BartArondson - on 10.8 the screen for About this Mac shows Mac Mini on one line then Late 2012 on the next – Mark Aug 6 '13 at 10:23
  • Ah I see it now. It's when you click on About This Mac and then on More Info.... I have no clue on how to get that information in your terminal. – Saaru Lindestøkke Aug 6 '13 at 10:43

You can indirectly get this information from a web page and the curl command. In the past this URL has been taken down and rate limited and put behind some sort of captcha to prevent this use, so you might need to resort to other avenues like https://checkcoverage.apple.com/ in that case.

Depending on if your serial numer is 11 or 12 characters long take the last 3 or 4 characters, respectively, and feed that to the following URL after the ?cc=XXXX part. If your serial number was 12 character and ended in DJWR, you would issue this command:

curl https://support-sp.apple.com/sp/product?cc=DJWR

To get your serial number, use the following command:

system_profiler SPHardwareDataType | awk '/Serial/ {print $4}'

Thus, you could have a complicated command to query the internet if you need a single command:

curl https://support-sp.apple.com/sp/product?cc=$(
  system_profiler SPHardwareDataType \
    | awk '/Serial/ {print $4}' \
    | cut -c 9-

and then run the output of that through sed to cut to the key part

curl -s https://support-sp.apple.com/sp/product?cc=$(
  system_profiler SPHardwareDataType \
    | awk '/Serial/ {print $4}' \
    | cut -c 9-
) | sed 's|.*<configCode>\(.*\)</configCode>.*|\1|'

There used to be a private library file with these mappings so you could consult it offline, but I noticed it was gone as of 10.8.3 (and perhaps earlier) so the above trick is the only one I know that works on the current OS without third party libraries.

Some nice third party libararies provide a look up of this:

Note that as of November 2017, Apple has forced the use of https over http for this service.

  • One more question. If I put the last option you gave me in terminal I get this: <?xml version="1.0" encoding="utf-8" ?><root><name>CPU Name</name><configCode>iMac (27-inch, Late 2009)</configCode><locale>en_US</locale></root>". Is it possible to just get "(27-inch, Late 2009)"? Tanks:P – Mac Aug 6 '13 at 12:48
  • So, does the More Info screen (the one the OP mentions) get its information from an on-line database? Isn't the marketing name stored locally somewhere if it's displayed there? – Saaru Lindestøkke Aug 6 '13 at 12:48
  • I think it is on a database. But in my case it's not a problem:P But if I can get it without internet it would be great of course. But if I only can get the text "(27-inch, Late 2009)" that would be great! Regards – Mac Aug 6 '13 at 12:58
  • My guess is the system caches it during registration or there is a private internal SDK for getting the information. It used to be in the private framework ServerKit - so it's clearly undocumented and has already changed. I know Mac can show the information without an internet connection - but I don't really know if it's cached or determined at install time and hard coded. – bmike Aug 6 '13 at 12:58
  • 2
    Similar to using sysctl -n hw.model mentioned below, ioreg -c IOPlatformExpertDevice -d 2 | awk -F\" '/IOPlatformSerialNumber/{print $(NF-1)}' will work faster for getting the serial number. – n8felton Sep 28 '16 at 18:30

You can use the command

system_profiler SPHardwareDataType | grep "Model Identifier"

in Terminal to get the model ID of your machine.
Then you can enter that ID on this site which will list the month and year the particular model was launched.

As mentioned in the comments below, the following command is much faster:

sysctl hw.model
  • 4
    system_profiler SPHardwareDataType | grep "Model Identifier" runs much faster than the full profiler, but still doesn't return the marketing name as the OP asked. See my answer for a command that works around the "look up" portion of your answer in a terminal friendly manner. – bmike Aug 6 '13 at 11:42
  • 1
    Your answer would be spot on for apple.stackexchange.com/questions/40243/… however ;-) – bmike Aug 6 '13 at 11:44
  • 4
    For the same output, sysctl hw.model is faster than the above command. – Liyali Sep 2 '14 at 10:00

On El Capitan and Sierra, there's a plist file in a private framework with a dict of info for each model identifier; that dict includes the marketing name (which has the model year in it). I don't know what OS version that particular file came in with, but it's NOT on Snow Leopard (the only thing I have that's older than El Capitan).

#! /bin/ksh
if [ -f /System/Library/PrivateFrameworks/ServerInformation.framework/Versions/A/Resources/English.lproj/SIMachineAttributes.plist ]
    marketingModel="$(modelid="$(system_profiler SPHardwareDataType 2>/dev/null|awk '/Model Identifier:/ {print $NF}')"
    defaults read /System/Library/PrivateFrameworks/ServerInformation.framework/Versions/A/Resources/English.lproj/SIMachineAttributes.plist "MacBookPro12,1"|sed -n -e 's/\\//g' -e 's/.*marketingModel = "\(.*\)";/\1/p')"
    echo "${marketingModel}"
    echo "can't use offline method to find marketing name on this OS version"

So, you could use that (or other similar tricks for other OS versions after checking the OS version, if you know those tricks, which I don't), and if that wasn't applicable, you could always fall back to the approach that requires Internet access.

This is not exactly the same as what About This Mac shows, which in my case is
MacBook Pro (Retina, 13-inch, Early 2015)
while this shows
13" MacBook Pro with Retina display (Early 2015)
but in human-readable terms, I think it's close enough.

  • I realize this answer is over 2 years old, but it's gotten the model identifier hardcoded (line 4, MacBookPro12,1) which means it always claims you're on an early 2015 13" mbp. – egid Dec 14 '18 at 20:52

Late to the game, but here's one approach:

hardware_model () {

  local hardware_mod=$(defaults read 
  ~/Library/Preferences/com.apple.SystemProfiler.plist 'CPU Names' \
  |cut -sd '"' -f 4 \


This function reads a plist file, looks for CPU Names within that file:

    "CPU Names" =     {
        "J1GN-en-US_US" = "iMac (Retina 5K, 27-inch, 2017)";

, then using the delimiter " parses out the fourth field:

iMac (Retina 5K, 27-inch, 2017) 

Tested to work on the currently supported versions of OS X.


Here is a one liner using PlistBuddy, without any grep, sed or awk-wardness.

/usr/libexec/PlistBuddy -c "print :$(sysctl -n hw.model):_LOCALIZABLE_:marketingModel" /System/Library/PrivateFrameworks/ServerInformation.framework/Versions/A/Resources/English.lproj/SIMachineAttributes.plist

this returns something like:

15" MacBook Pro with Thunderbolt 3 and Touch ID (Mid 2017)


Another one liner that yields a slightly different string, also using PlistBuddy (with a tiny bit of awk):

/usr/libexec/PlistBuddy -c "print :'CPU Names':$(system_profiler SPHardwareDataType | awk '/Serial/ {print $4}' | cut -c 9-)-en-US_US" ~/Library/Preferences/com.apple.SystemProfiler.plist

MacBook Pro (15-inch, 2017)

Credit to several of the above answers for this.


Combining Saaru's answer with a debugged version of Richard Hamilton's I get the following, which works 10.6 thru 10.12 (though the sample size on 10.6 is just one machine) and possibly earlier/later, and does not depend on a connection to the internet and Apple's servers not changing

if ! [ -f "${ATTRIBSFILE}.plist" ] ; then
  # 10.7 or 10.6
if [ -f "${ATTRIBSFILE}.plist" ]
    modelid="$(sysctl -n hw.model)"
    marketingModel="$(defaults read "${ATTRIBSFILE}" "${modelid}" |sed -n -e 's/\\//g' -e 's/.*marketingModel = "\(.*\)";/\1/p')"
    echo "${marketingModel}"
    echo "can't use offline method to find marketing name on this OS version"

Some notes on what I discovered to get here:

  • We have to strip ".plist" off the domain for defaults to work in 10.6, and therefore re-add it manually to the shell -f tests
  • the -n flag to sysctl means it prints only the value, saving us some sed or awk work

We have some 2019 MBPs that return different year models for the two one-liners posted by tabrindle.

His first one-liner (using sysctl -n hw.model) returns 2018 for a 2019 model:

Wrong: 15" MacBook Pro with Thunderbolt 3 and Touch ID (Mid 2018)

But his second one-liner (using system_profiler SPHardwareDataType) returns the correct name:

Right: MacBook Pro (15-inch, 2019)


This should do it:

system_profiler | more
scutil --get ComputerName
sw_vers | awk -F':\t' '{print $2}' | paste -d ' ' - - -
sysctl -n hw.memsize | awk '{print $0/1073741824" GB RAM"}'
sysctl -n machdep.cpu.brand_string
  • 3
    None of the commands you've listed do what the question asker asks. – Saaru Lindestøkke Aug 6 '13 at 10:08

You must log in to answer this question.

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