

You can have multiple CPUs that share one core - this is called hyperthreading. every core has an ALU, a memory unit, etc.) For instance, arithmetic instructions are actually performed by an ALU (arithmetic/logic unit), while instructions that load/store from memory are executed by some sort of memory unit.Ī core refers to a set of actual execution hardware (i.e. The decision logic inside a CPU will dispatch the different instructions to different hardware units. There are different types of instructions. A CPU has logic that figures out what the bits of an instruction mean and decides what to do with it.


$ lscpu -all -parse=CPU,SOCKET,CORE | grep -v '^#' The lscpu command has a number of useful options that you may like to check out, for example: $ lscpu -all -extended In the case of the server system listed above we expect to see 8 cores per socket and 16 threads per socket: $ sudo dmidecode -t 4 | grep -E 'Socket Designation|Count' To specifically answer your question you tell how many cores you have by multiplying the number of cores you have per socket by the number of sockets you have.įor the example systems above the desktop has 4 cores: $ echo "Cores = $(( $(lscpu | awk '/^Socket\(s\)/') ))"Īnother useful utility is dmidecode which outputs per socket information. For the desktop machine above this should match the 4 Core(s) per socket reported by lscpu: $ grep -m 1 'cpu cores' /proc/cpuinfo The cpu cores reported by /proc/cpuinfo corresponds to the Core(s) per socket reported by lscpu. The output of /proc/cpuinfo should match this information, for example on the desktop system above we can see there are 8 processors (CPUs) and 4 cores (core id 0-3): $ grep -E 'processor|core id' /proc/cpuinfo For the desktop machine above this should match the 8 CPU(s) reported by lscpu: $ nproc -all The output of nproc corresponds to the CPU count from lscpu.

Here is an example from a desktop machine: $ lscpu | grep -E '^Thread|^Core|^Socket|^CPU\('Īnd a server: $ lscpu | grep -E '^Thread|^Core|^Socket|^CPU\(' If you multiply these numbers you will get the number of CPUs on your system.ĬPUs = Threads per core X cores per socket X socketsĬPUs are what you see when you run htop (these do not equate to physical CPUs). Model name : Intel(R) Xeon(R) CPU 5130 2.00GHzįlags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl vmx tm2 cx16 xtpr lahf_lmĪddress sizes : 36 bits physical, 48 bits virtualįirst, what does all of that actually mean? I see I have a processor 0 and processor 1.To get a complete picture you need to look at the number of threads per core, cores per socket and sockets. When running cat /proc/cpuinfo under Linux, a variety information is kicked-back.
