Is there a simple UNIX command for finding out how many cores I have to work with?
I've got an Ubuntu VM on my Mac. Is there a command I can run in Ubuntu that will tell me how many cores I have to work with?
I could do "about this mac" on the host, but I'm not sure how well the multi-core processor would translate to the VM.
Solution 1:
This should work:
grep -c processor /proc/cpuinfo
or
lshw -class processor -short
Solution 2:
On OS X you can use sysctl or system_profiler:
$ sysctl hw.ncpu hw.physicalcpu hw.logicalcpu
hw.ncpu: 8
hw.physicalcpu: 4
hw.logicalcpu: 8
$ sysctl -n hw.ncpu # -n disables printing the names of variables
8
$ system_profiler SPHardwareDataType|grep Cores
Total Number of Cores: 4
My processor supports hyper-threading, so there are 8 logical cores and 4 physical cores.