14

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.

1
  • You have configured your VM to have more than CPU, right? (Just making sure)
    – Daniel Beck
    Feb 18, 2011 at 6:21

4 Answers 4

26

This should work:

grep -c processor /proc/cpuinfo

or

lshw -class processor -short
2
  • 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.
    – Piper
    Aug 18, 2012 at 22:07
  • 2
    @Islay: It's because it's hyperthreaded. Aug 18, 2012 at 22:16
5

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.

1

This command will do the job: dmesg | grep cpu

1
  • Nopes. This just shows all messages relating to CPU. Check above answers or use lscpu Sep 28, 2016 at 7:24
0

lscpu would list out the CPUs and their cores.

You must log in to answer this question.

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