How to check number of CPUs are there in Linux system

One can use any one of the following command to find the number of physical CPU cores including all cores on Linux:

  • lscpu command
  • cat /proc/cpuinfo
  • top or htop command
  • nproc command


Just run the lscpu command:

lscpu
lscpu | egrep 'Model name|Socket|Thread|NUMA|CPU\(s\)'
lscpu -p
[root@shsdascn7i ~]# lscpuArchitecture:          x86_64CPU op-mode(s):        32-bit, 64-bitByte Order:            Little EndianCPU(s):                2On-line CPU(s) list:   0,1Thread(s) per core:    1Core(s) per socket:    1Socket(s):             2NUMA node(s):          1Vendor ID:             GenuineIntelCPU family:            6Model:                 158Model name:            Intel(R) Core(TM) i7-8700 CPU @ 3.20GHzStepping:              10CPU MHz:               3191.998CPU max MHz:           0.0000CPU min MHz:           0.0000BogoMIPS:              6383.99Hypervisor vendor:     VMwareVirtualization type:   fullL1d cache:             32KL1i cache:             32KL2 cache:              256KL3 cache:              12288KNUMA node0 CPU(s):     0,1Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch epb fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm rdseed adx smap xsaveopt dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp

The following line indicates that I have two physical CPUs:

CPU socket(s):         2
cat /proc/cpuinfo
OR
more /proc/cpuinfo[root@shsdascn7i ~]# cat /proc/cpuinfoprocessor       : 0vendor_id       : GenuineIntelcpu family      : 6model           : 158model name      : Intel(R) Core(TM) i7-8700 CPU @ 3.20GHzstepping        : 10microcode       : 0xb4cpu MHz         : 3191.998cache size      : 12288 KBphysical id     : 0siblings        : 1core id         : 0cpu cores       : 1apicid          : 0initial apicid  : 0fpu             : yesfpu_exception   : yescpuid level     : 22wp              : yesflags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch epb fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm rdseed adx smap xsaveopt dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_eppbogomips        : 6383.99clflush size    : 64cache_alignment : 64address sizes   : 42 bits physical, 48 bits virtualpower management:
processor       : 1vendor_id       : GenuineIntelcpu family      : 6model           : 158model name      : Intel(R) Core(TM) i7-8700 CPU @ 3.20GHzstepping        : 10microcode       : 0xb4cpu MHz         : 3191.998cache size      : 12288 KBphysical id     : 2siblings        : 1core id         : 0cpu cores       : 1apicid          : 2initial apicid  : 2fpu             : yesfpu_exception   : yescpuid level     : 22wp              : yesflags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch epb fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm rdseed adx smap xsaveopt dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_eppbogomips        : 6383.99clflush size    : 64cache_alignment : 64address sizes   : 42 bits physical, 48 bits virtualpower management:

Let us print cpu thread count:
echo "CPU threads: $(grep -c processor /proc/cpuinfo)"
grep 'cpu cores' /proc/cpuinfo | uniq

top - 15:54:25 up 9 days, 23:17,  2 users,  load average: 3.79, 2.87, 2.32Tasks: 491 total,   1 running, 490 sleeping,   0 stopped,   0 zombie%Cpu(s):  4.1 us,  6.0 sy,  0.0 ni, 29.1 id, 60.5 wa,  0.0 hi,  0.3 si,  0.0 stKiB Mem :  9810952 total,   133368 free,  7078720 used,  2598864 buff/cacheKiB Swap: 12697596 total, 10402480 free,  2295116 used.   794624 avail Mem
   PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND 12341 apdascn+  20   0 1474108  81472   3028 S  16.9  0.8   0:39.14 java 28754 ordascn+  -2   0 2564436   2276   1876 S   1.3  0.0 293:00.05 ora_vktm_cdbebs    35 root      20   0       0      0      0 S   1.0  0.0   7:00.63 kswapd0 95348 apdascn+  20   0 2841624 751960      0 S   0.7  7.7   4:30.52 java     9 root      20   0       0      0      0 S   0.3  0.0   6:04.69 rcu_sched  9661 root      20   0       0      0      0 S   0.3  0.0   1:41.58 jbd2/sdd1-8  9673 root      20   0       0      0      0 S   0.3  0.0   1:55.88 jbd2/sdc1-8 10467 root      20   0       0      0      0 S   0.3  0.0   0:00.56 kworker/0:0 12186 apdascn+  20   0 1856860 290032    484 S   0.3  3.0   0:07.77 java 12524 root      20   0  162308   2660   1560 R   0.3  0.0   0:00.13 top 28770 ordascn+  20   0 2672080  31740  27912 S   0.3  0.3   4:42.92 ora_scmn_cdbebs 28802 ordascn+  20   0 2564440  35232  34200 S   0.3  0.4   5:37.36 ora_ckpt_cdbebs 97935 apdascn+  20   0 1754184 136872   1632 S   0.3  1.4   0:35.74 java 99473 apdascn+  20   0 2312444 865848      0 S   0.3  8.8   3:20.05 java117218 ordascn+  20   0 2568340 195068 189264 S   0.3  2.0   0:06.54 ora_m008_cdbebs     1 root      20   0  195224   3040    596 S   0.0  0.0   0:32.65 systemd     2 root      20   0       0      0      0 S   0.0  0.0   0:00.63 kthreadd     3 root      20   0       0      0      0 S   0.0  0.0   1:32.14 ksoftirqd/0     5 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 kworker/0:0H     7 root      rt   0       0      0      0 S   0.0  0.0   0:01.99 migration/0     8 root      20   0       0      0      0 S   0.0  0.0   0:00.00 rcu_bh    10 root       0 -20       0      0      0 S   0.0  0.0   0:00.00 lru-add-drain    11 root      rt   0       0      0      0 S   0.0  0.0   0:15.58 watchdog/0

Another option is to run lovely htop:
htop

Execute nproc print the number of CPUs available on Linux

Let us print the number of installed processors on your system i.e core count:
nproc --all
echo "Threads/core: $(nproc --all)"

Sample outputs:

[root@shsdascn7i ~]# echo "Threads/core: $(nproc --all)"
Threads/core: 2

Comments

Popular posts from this blog

How to fix Oracle SQL Developer connection issue "Got minus one from a read call"

How to drop index and before dropping it how to get the DDL.

How to troubleshoot Long Running Concurrent Request in EBS 12.2

How to autopopulate user_guid in fnd_user table ( EBS Blank Page)

Opatch is getting faild for GI patch with error code 2 while doing prereq

Few Important steps of Oracle Database Clone

How to Check AD and TXK code levels in your EBS environment

The Server is not able to service this request: [Socket:000445]Connection rejected, filter blocked Socket, weblogic.security.net.FilterException

CPU Patch Analysis

PRVG-11250 : The check "RPM Package Manager database" was not performed because