A CPU is an acronym for the central processing unit. It is an essential part of a computer. The CPU sends signals that control the other part of the Linux server. You can call it as the brain of your computer. This page shows how to find out the number of CPUs on Linux using the command line.
Linux determines the number of CPUs using the lscpu command:
lscpu
How do I display the number of processing units available?
You can show the number of processing units available to the current process including all installed processors:
nproc --all
Another option to obtain the number of CPUs/cores in Linux. Run the following command:
getconf _NPROCESSORS_ONLN
Use the cat command to see info about your CPU and system architecture dependent items, for each supported architecture a different list:
cat /proc/cpuinfo
You can use the combination of grep command and wc command as follows to print
grep processor /proc/cpuinfo | wc -l echo "Total logical core(s): $(grep processor /proc/cpuinfo | wc -l)" echo "Core per cpu: $(grep '^core id' /proc/cpuinfo | sort -u | wc -l)"
The output from /proc/cpuinfo can be difficult to phrase. Therefore, it is better to use the lscpu command:
lscpu
Sample outputs:
Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 24 On-line CPU(s) list: 0-23 Thread(s) per core: 1 Core(s) per socket: 1 Socket(s): 24 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 79 Model name: Intel(R) Xeon(R) CPU E5-2697 v4 @ 2.30GHz Stepping: 1 CPU MHz: 2299.994 BogoMIPS: 4599.98 Hypervisor vendor: KVM Virtualization type: full L1d cache: 32K L1i cache: 32K L2 cache: 4096K L3 cache: 16384K NUMA node0 CPU(s): 0-23 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl xtopology cpuid tsc_known_freq 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 cpuid_fault invpcid_single pti fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx smap xsaveopt arat