How can I get CPU count and total RAM from the OS X command line?

link|improve this question

69% accept rate
feedback

2 Answers

up vote 8 down vote accepted
scorp@antani-mac:~$ hwprefs cpu_count
2
scorp@antani-mac:~$ hwprefs memory_size
4.00 GB
link|improve this answer
hwprefs doesn't seem to be part of the default OS X install (I think it's in Xcode, or maybe the CHUD tools). – Gordon Davisson Feb 16 '10 at 4:50
hwprefs: command not found on Mac Os x Lion – aleroot Nov 6 '11 at 10:20
feedback

You can get this from the system_profiler tool:

system_profiler | grep "  Memory:"
system_profiler | grep Cores:
system_profiler | grep Processors:

or, if you want to go low-level, use sysctl:

sysctl hw.memsize
sysctl hw.ncpu

btw, there are a bunch of other interesting things you can get from sysctl. Try:

sysctl -a | grep cpu

to see a few of them

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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