Techolac - Computer Technology News
  • Home
  • Internet
  • Business
  • Computers
  • Gadgets
  • Lifestyle
  • Phones
  • Travel
  • Tech
  • More
    • Automotive
    • Education
    • Entertainment
    • Health
    • SEO
    • Linux
    • WordPress
    • Home Improvement
    • How to
    • Games
No Result
View All Result
  • Home
  • Internet
  • Business
  • Computers
  • Gadgets
  • Lifestyle
  • Phones
  • Travel
  • Tech
  • More
    • Automotive
    • Education
    • Entertainment
    • Health
    • SEO
    • Linux
    • WordPress
    • Home Improvement
    • How to
    • Games
No Result
View All Result
Techolac - Computer Technology News
No Result
View All Result
Home Linux

Check how many CPUs are there in Linux system

by Editorial Staff
November 7, 2018
in Linux
Reading Time: 4 mins read

[ad_1]

I am a new Linux user. How do you check how many CPUs are there in Linux system using the command line option?

Introduction: One can obtain the number of CPUs or cores in Linux from the command line. The /proc/cpuinfo file stores CPU and system architecture dependent items, for each supported architecture. You can view /proc/cpuinfo with the help of cat command or grep command/egrep command. This page shows how to use /proc/cpuinfo file and lscpu command to display number of processors on Linux.

How do you check how many CPUs are there in Linux system?

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

  1. lscpu command
  2. cat /proc/cpuinfo
  3. top or htop command
  4. nproc command
  5. hwinfo command
  6. dmidecode -t processor command
  7. getconf _NPROCESSORS_ONLN command

Let us see all commands and examples in details.

How to display information about the CPU on Linux

Just run the lscpu command:
$ lscpu
$ lscpu | egrep 'Model name|Socket|Thread|NUMA|CPU(s)'
$ lscpu -p

Check how many CPUs are there in Linux system
The output clearly indicate that I have:

  1. CPU model/make: AMD Ryzen 7 1700 Eight-Core Processor
  2. Socket: Single (1)
  3. CPU Core: 8
  4. Thread per core: 2
  5. Total threads: 16 ( CPU core[8] * Thread per core [2])

Use /proc/cpuinfo to find out how many CPUs are there in Linux

The lscpu command gathers CPU architecture information from sysfs, /proc/cpuinfo and other sources. To view use the cat command and more command as follows:
$ cat /proc/cpuinfo
OR
$ more /proc/cpuinfo
Command To Check Number Of CPU Cores On Linux
Let us print cpu thread count:
$ echo "CPU threads: $(grep -c processor /proc/cpuinfo)"
$ grep 'cpu cores' /proc/cpuinfo | uniq

Run top or htop command to obtain the number of CPUs/cores in Linux

Simply run the following command and hit ‘1’:
$ top
Obtain the number of CPUs cores in Linux from the command line
Another option is to run lovely htop:
$ htop
Show number of cores of a system in Linux with htop

How do I Find Out Linux CPU Utilization?

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:

Threads/core: 16

How to probe for CPU/core on Linux using hwinfo command

$ hwinfo --cpu --short ## short info ##
$ hwinfo --cpu ## detailed info on CPUs ##

Linux see CPU core information with hwinfo

Linux display CPU core with getconf _NPROCESSORS_ONLN command

One can query Linux system configuration variables with getconf command:
$ getconf _NPROCESSORS_ONLN
$ echo "Number of CPU/cores online at $HOSTNAME: $(getconf _NPROCESSORS_ONLN)"

Sample outputs:

Number of CPU/cores online at nixcraft-asus.nixcraft.com: 16

dmidecode -t processor command

You can use get BIOS and hardware information with dmidecode command (DMI table decoder) on Linux. To find out how many CPUs are there in Linux system, run:
$ sudo dmidecode -t 4
$ sudo dmidecode -t 4 | egrep -i 'core (count|enabled)|thread count|Version'

Linux dmidecode show CPU thread and core count

Linux Setting processor affinity for a certain task or process

Here is a quick video demo of lscpu and other commands:

Conclusion

You learned how to display information about the CPU architecture, core, threads, CPU version/model, vendor and other information using various Linux command line options.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

[ad_2]

Related Posts

Top 5 MySQL Performance Tuning Tips
Linux

Top 5 MySQL Performance Tuning Tips

January 25, 2023
Top Commands to Check the Running Processes in Linux
Linux

Top Commands to Check the Running Processes in Linux

May 27, 2022
4 Tips to Prevent and Troubleshoot the ImagePullBackOff Kubernetes Error
Linux

4 Tips to Prevent and Troubleshoot the ImagePullBackOff Kubernetes Error

March 30, 2022

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Articles

  • Top 26 Best AniWorld Alternatives To Watch Anime Free
  • The Power of Good UI/UX Design in Driving Sales: A Comprehensive Guide
  • Use eBook Content Development to Enhance Your Real Estate Business
  • 30 CoolMovieZone Alternatives To Watch Movies HD Online
  • Private Equity Trends: Expectations Vs Reality
  • The Importance of a Digital Strategy For Business Growth
  • Top 26 Best AnimeGG Alternatives To Watch Anime Free
  • DashTech
  • TechDaddy
  • Terms and Conditions
  • Disclaimer
  • Write for us

© Techolac © Copyright 2019 - 2022, All Rights Reserved.

No Result
View All Result
  • Home
  • Internet
  • Business
  • Computers
  • Gadgets
  • Lifestyle
  • Phones
  • Travel
  • Tech
  • More
    • Automotive
    • Education
    • Entertainment
    • Health
    • SEO
    • Linux
    • WordPress
    • Home Improvement
    • How to
    • Games

© Techolac © Copyright 2019 - 2022, All Rights Reserved.