Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
    
You have configured your VM to have more than CPU, right? (Just making sure) – Daniel Beck Feb 18 '11 at 6:21

This should work:

grep -c processor /proc/cpuinfo

or

lshw -class processor -short
share|improve this answer
    
I tried the grep -c processor /proc/cpuinfo and the output was 4. I'm confused because my box has an i3 in it, and I thought those were dual cores. – piperchester Aug 18 '12 at 22:07
2  
@Islay: It's because it's hyperthreaded. – Dennis Williamson Aug 18 '12 at 22:16

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.

share|improve this answer

This command will do the job: dmesg | grep cpu

share|improve this answer

You must log in to answer this question.

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