Check how many CPUs are there in Linux system
last updated October 15, 2018 in CategoriesCentOS, Debian / Ubuntu, Hardware, Linux, RedHat and Friends, Suse
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:
-
lscpu command
-
cat /proc/cpuinfo
-
top or htop command
-
nproc command
-
hwinfo command
-
dmidecode -t processor command
-
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
The output clearly indicate that I have:
-
CPU model/make: AMD Ryzen 7 1700 Eight-Core Processor
-
Socket: Single (1)
-
CPU Core: 8
-
Thread per core: 2
-
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
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
'IT > Linux' 카테고리의 다른 글
[Linux] Grafana 설치 및 실행 (0) | 2020.11.29 |
---|---|
[Linux] watch 명령을 이용한 linux 시스템 모니터링 (0) | 2020.11.29 |
[Tomcat] CentOS 7에 Tomcat8 설치 및 설정 (0) | 2020.11.29 |
[Linux] vi 한글 깨짐, 터미널 한글 깨짐 (0) | 2020.11.29 |
[Linux] Centos 7 캐릭터셋 변경 – locale 변경 (0) | 2020.11.29 |