Tell me more ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Does anybody know a terminal command that gives me the 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.

share|improve this question
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. – Bart Arondson Aug 6 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 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. – Bart Arondson Aug 6 at 10:43

4 Answers

up vote 16 down vote accepted

You can indirectly get this information from a web page and the curl command.

Take the last 4 characters of your serial number and feed that to the following URL after the ?cc=XXXX part. If your serial number ended in DJWR, you would issue this command:

curl http://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 http://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 http://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.

share|improve this answer
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 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? – Bart Arondson Aug 6 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 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 at 12:58
I boot from a external hard drive to different computers everyday. And I run different commands in geek tool that gives me information about the mac I currently work on. To have that information via a terminal command save me alot of time. :P – Mac Aug 6 at 13:10
show 4 more comments

You can use the command

system_profiler | 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.

share|improve this answer
2  
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 at 11:42
Your answer would be spot on for apple.stackexchange.com/questions/40243/… however ;-) – bmike Aug 6 at 11:44

This should do it:

system_profiler | more
sw_vers
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

Other References

share|improve this answer
2  
None of the commands you've listed do what the question asker asks. – Bart Arondson Aug 6 at 10:08

Download Macktracker, An app for Osx avalable for iOS.

http://mactracker.ca/

You Will get all info your need ...

share|improve this answer
1  
Hello and welcome to Apple.SE. Could you maybe explain how this app will help the OP use the Terminal to determine the model number, as that is what the OP asks? – Bart Arondson Aug 6 at 22:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.