How To Check CPU Information In LINUX Environment

LINUX_www.basisguru.com

As a Basis consultant, we need to monitor the OS performance & get the resource details like CPU information,hardware details etc.
There are multiple ways to get the CPU information in LINUX/UNIX environment.

We will discuss following two ways:

  • via /proc/cpuinfo
  • via command lscpu

File /proc/cpuinfo will display the CPU information such as processor,CPU cores,cache size etc.

<hostname> ➤ cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 142
model name      : Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
stepping        : 10
cpu MHz         : 1896.000
cache size      : 256 KB
physical id     : 0
siblings        : 8
core id         : 0
cpu cores       : 4
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 22
wp              : yes
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 pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 fma cx16 xtpr pdcm sse4_1 sse4_2 x2apic movbe popcnt aes xsave osxsave avx f16c rdrand lahf_lm ida arat epb xsaveopt pln pts dtherm fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt
clflush size    : 64
cache_alignment : 64
address sizes   : 39 bits physical, 48 bits virtual
power management:

---------------------------------------------------------------------------

processor       : 7
vendor_id       : GenuineIntel
cpu family      : 6
model           : 142
model name      : Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
stepping        : 10
cpu MHz         : 1896.000
cache size      : 256 KB
physical id     : 0
siblings        : 8
core id         : 3
cpu cores       : 4
apicid          : 7
initial apicid  : 7
fpu             : yes
fpu_exception   : yes
cpuid level     : 22
wp              : yes
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 pni dtes64 monitor ds_cpl vmx smx est tm2 ssse3 fma cx16 xtpr pdcm sse4_1 sse4_2 x2apic movbe popcnt aes xsave osxsave avx f16c rdrand lahf_lm ida arat epb xsaveopt pln pts dtherm fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt
clflush size    : 64
cache_alignment : 64
address sizes   : 39 bits physical, 48 bits virtual

Let us discuss few important terminology in detail for linux cpu info as below:

Processor:

This will display the number of processors on the machine.
0 means machine has only one processor.
In case of multiple processors, it will display them sequentially starting from 0. (see fig-2, we have total 8 processors)
Here processor 0 is on core- 0 and processor 7 is on core-3 (see line core_id).

Core Id:

Denotes the number of cores (here we have cores 0-3 i.e. 4 cores).

Model name:

Self explanatory 🙂

Cache size:

tells us the size of temporary storage area that the computer’s processor can retrieve data in much faster way. (L2 cache).

FPU:

Stands for floating point unit.It’s a part of processor used for floating point calculations.

Siblings:

shows number of processors attached to the same physical processor.

Apicid:

denotes the number of virtual as given by bios.

LSCPU method to get CPU information in Linux:

lscpu fetches the details of system architecture details from sysfs and /proc/cpuinfo.

The information will display details like threads,sockets,NUMA (Non-Uniform Memory Access),information about caches and cache sharing,model, bogoMIPS, stepping and byte order.

><hostname>:~$ lscpu
>Architecture:          x86_64
>CPU op-mode(s):        32-bit, 64-bit
>Byte Order:            Little Endian
>CPU(s):                56
>On-line CPU(s) list:   0-55
>Thread(s) per core:    2
>Core(s) per socket:    14
>Socket(s):             2
>NUMA node(s):          2
>Vendor ID:             GenuineIntel
>CPU family:            6
>Model:                 142
>Model name:            Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
>Stepping:              1
>CPU MHz:               2600.000
>CPU max MHz:           2600.0000
>CPU min MHz:           1200.0000
>BogoMIPS:              5201.37
>Virtualization:        VT-x
>Hypervisor vendor:     vertical
>Virtualization type:   full
>L1d cache:             32K
>L1i cache:             32K
>L2 cache:              256K
>L3 cache:              35840K
>NUMA node0 CPU(s):     0-13,28-41
>NUMA node1 CPU(s):     14-27,42-55