How to Get the Processor Core Number Information of a Machine

Posted on

This is an article showing on how to check the core number of the processor. The process exist in a machine with a Linux operating system in it. The machine itself actually can be a server, laptop or PC. That machine with the operating system available in it can print the information of the number of the processor. Usually, there are several ways for printing the information regarding the number of the core processor. Those are really just commands. One of the available command is the ‘lscpu’. According to the manual page, the ‘lscpu’ command is a command where it can display or print the information about the CPU architecture. The following is an example of the command usage :

user@hostname:~$ lscpu
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
CPU(s):              8
On-line CPU(s) list: 0-7
Thread(s) per core:  2
Core(s) per socket:  4
Socket(s):           1
NUMA node(s):        1
Vendor ID:           GenuineIntel
CPU family:          6
Model:               142
Model name:          Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Stepping:            10
CPU MHz:             953.706
CPU max MHz:         4000.0000
CPU min MHz:         400.0000
BogoMIPS:            3984.00
Virtualization:      VT-x
L1d cache:           32K
L1i cache:           32K
L2 cache:            256K
L3 cache:            8192K
NUMA node0 CPU(s):   0-7
Flags:               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 pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d
user@hostname:~$  

The output above is only an example. It can be different from one machine to another. The above output is a complete output printing all of the CPU architecture. But the important one in this context it is not to be able to get all the information instead only the number of the core processor. In order to display only the core number of the processor, just modify the command to filter the output as follows :

user@hostname:~$ lscpu | egrep 'CPU\(s\)'
CPU(s):              8
On-line CPU(s) list: 0-7
NUMA node0 CPU(s):   0-7
user@hostname:~$

Finally, according to the output above, the number of the core available in the processor is 8. The output above is also different from one machine with another one. It depends on the processor available on the machine, the output is also different.

Leave a Reply