- 9 Commands to Check CPU Information on Linux
- CPU hardware information
- 1. /proc/cpuinfo
- 2. lscpu — display information about the CPU architecture
- 3. hardinfo
- 4. lshw
- 5. nproc
- 6. dmidecode
- 7. cpuid
- 8. inxi
- 9. Hwinfo
- Conclusion
- 15 thoughts on “ 9 Commands to Check CPU Information on Linux ”
- 9 Useful Commands to Get CPU Information on Linux
- 1. Get CPU Info Using cat Command
- 2. lscpu Command – Shows CPU Architecture Info
- 3. cpuid Command – Shows x86 CPU
- 4. dmidecode Command – Shows Linux Hardware Info
- 5. Inxi Tool – Shows Linux System Information
- 6. lshw Tool – List Hardware Configuration
- 7. hardinfo – Shows Hardware Info in GTK+ Window
- 8. hwinfo – Shows Present Hardware Info
- 9. nproc – Print Number of Processing Units
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- Как в Linux узнать всю информацию о процессоре
- Информация о процессоре
- 1. Поставщик и модель процессора
- 2. Архитектура
- 3. Частота
- 4. Количество ядер
- Несколько процессоров
- 5. Технология Hyper threading
- Процессор с технологией hyper threading
- Утилита hwloc / lstopo
- Процессор с технологией hyper threading
9 Commands to Check CPU Information on Linux
CPU hardware information
The cpu information includes details about the processor, like the architecture, vendor name, model, number of cores, speed of each core etc.
There are quite a few commands on linux to get those details about the cpu.
In this post we shall take a look at some of the commonly used commands that can be used to get details about the cpu.
1. /proc/cpuinfo
The /proc/cpuinfo file contains details about individual cpu cores.
Output its contents with less or cat.
Every processor or core is listed separately the various details about speed, cache size and model name are included in the description.
To count the number of processing units use grep with wc
To get the actual number of cores, check the core id for unique values
So there are 4 different core ids. This indicates that there are 4 actual cores.
2. lscpu — display information about the CPU architecture
lscpu is a small and quick command that does not need any options. It would simply print the cpu hardware details in a user-friendly format.
3. hardinfo
Hardinfo is a gtk based gui tool that generates reports about various hardware components. But it can also run from the command line only if there is no gui display available.
It would produce a large report about many hardware parts, by reading files from the /proc directory. The cpu information is towards the beginning of the report. The report can also be written to a text file.
Hardinfo also performs a few benchmark tests taking a few minutes before the report is displayed.
4. lshw
The lshw command can display limited information about the cpu. lshw by default shows information about various hardware parts, and the ‘-class’ option can be used to pickup information about a specific hardware part.
The vendor, model and speed of the processor are being shown correctly. However it is not possible to deduce the number of cores on the processor from the above output.
5. nproc
The nproc command just prints out the number of processing units available. Note that the number of processing units might not always be the same as number of cores.
6. dmidecode
The dmidecode command displays some information about the cpu, which includes the socket type, vendor name and various flags.
7. cpuid
The cpuid command fetches CPUID information about Intel and AMD x86 processors.
The program can be installed with apt on ubuntu
And here is sample output
8. inxi
Inxi is a script that uses other programs to generate a well structured easy to read report about various hardware components on the system. Check out the full tutorial on inxi.
Print out cpu/processor related information
To learn more about the inxi command and its usage check out this post:
Inxi is an amazing tool to check hardware information on Linux
9. Hwinfo
The hwinfo command is a hardware information program that can be used to collect details about various hardware components on a Linux system.
It also displays information about the processor. Here is a quick example:
If you don’t use the «—short» option it will display much more information about each cpu core like architecture and processor features.
To learn more about the hwinfo command check this post:
Check hardware information on Linux with hwinfo command
Conclusion
Those were some of the commands to check CPU information on Linux based systems like Ubuntu, Fedora, Debian, CentOS etc.
For some more command examples on checking cpu information check this post:
How to Check Processor and CPU Details on Linux — Command Examples
Most of the commands are command line based and show text output. For a GUI interface use the program called Hardinfo.
It shows hardware details about various components in a easy to use GUI interface.
If you know of any other useful command that can display information about the CPU, let us know in the comments below.
A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected] .
15 thoughts on “ 9 Commands to Check CPU Information on Linux ”
Very nicely explained. I highly recommend it in my articles. thank you.
Thank you for the information, i learn lot in this article. 🙂
Thanks for the Information.
Hi everybody, someone know how to get same information regarding the hardware where I installed a phisical linux ?
Thank you for sharing, it helping lot.
lshw now (DISTRIB_DESCRIPTION=”Linux Mint 17.3 Rosa”) includes a line like below at the bottom of it’s listing:
configuration: cores=4 enabledcores=4 threads=8
How to get the number of real cores, not HiperThreading.
For example, for i7, real cores are 4, but logical are 8. There is some way without root ?
check this post for commands to check the number of real cores.
https://www.binarytides.com/linux-check-processor/
are we still catting into grep?
grep ‘core id’ /proc/cpuinfo
yo Silver Moon, nice write-up bro. absolutelly useful stuff there, though the number of CPUs can be fetched using just ‘grep -c processor /proc/cpuinfo’. take care 🙂
Thank you for the helpful information. You can not look for “unique values” with the “cat /proc/cpuinfo |grep ‘core id’” command on a multiprocessor system. The situation gets even worse with hyperthreading enabled CPU’s.
Источник
9 Useful Commands to Get CPU Information on Linux
In a previous article, we put together a list of 10 useful commands to collect system and hardware information in Linux. In this guide, we will narrow down to the CPU/processor, and show you various ways of extracting detailed information about your machine CPU.
Just to give you an overview, we will query information such as CPU architecture, vendor_id, model, model name, number of CPU cores, speed of each core, and lots more.
Essentially, the /proc/cpuinfo contains this all info, every other command/utility gets its output from this file.
With that said, below are 9 commands for getting info about your Linux CPU.
1. Get CPU Info Using cat Command
You can simply view the information of your system CPU by viewing the contents of the /proc/cpuinfo file with the help of cat command as follows:
To get a little specific, you can employ the grep command – a CLI tool for searching plain-text data for lines matching a regular expression. This can help you only output vendor name, model name, number of processors, number of cores, etc:
2. lscpu Command – Shows CPU Architecture Info
The command lscpu prints CPU architecture information from sysfs and /proc/cpuinfo as shown below:
3. cpuid Command – Shows x86 CPU
The command cpuid dumps complete information about the CPU(s) collected from the CPUID instruction, and also discover the exact model of x86 CPU(s) from that information.
Make sure to install it before running it.
Once installed, run cpuid to collect information concerning the x86 CPU.
4. dmidecode Command – Shows Linux Hardware Info
dmidecode is a tool for retrieving hardware information of any Linux system. It dumps a computer’s DMI (a.k.a SMBIOS) table contents in a human-readable format for easy retrieval. The SMBIOS specification defines various DMI types, for CPU, use “processor” as follows:
5. Inxi Tool – Shows Linux System Information
Inxi is a powerful command-line system information script intended for both console and IRC (Internet Relay Chat). You can use it to instantly retrieve hardware information.
You can install like so:
To display complete CPU information, including per CPU clock-speed and CPU max speed (if available), use the -C flag as follows:
6. lshw Tool – List Hardware Configuration
lshw is a minimal tool for gathering in-depth information on the hardware configuration of a computer. You can use the -C option to select the hardware class, CPU in this case:
7. hardinfo – Shows Hardware Info in GTK+ Window
hardinfo displays hardware information in a GTK+ window, you can install it as follows:
Once you have it installed, type:
Linux System Information
It also enables you to generate a system hardware info report by clicking on the “Generate Report” button. From the interface below, click on “Generate” to proceed. Note that you can choose the hardware info category to be generated.
Generate System Information Report
Once you have generated the report in html format, you can view it from a web browser as shown below.
Linux System Detailed Information
8. hwinfo – Shows Present Hardware Info
hwinfo is used to extract info about the hardware present in a Linux system. To display info about your CPU, use the —cpu
9. nproc – Print Number of Processing Units
nproc command is used to show the number of processing unit present on your computer:
For additional usage info and options, read through the man pages of these commands like this:
That’s it for now! You can share with us additional ways of extracting CPU information in Linux via the feedback form below.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник
Как в Linux узнать всю информацию о процессоре
Информация о процессоре
Подробная информация о процессоре, о которой мы будем говорить, содержит в себе сведения о количестве ядер, о наличии режима hyper threading, об архитектуре, о размере кэша и т. д. Найти в вашей системе эту информацию, относящуюся к процессору, может быть слегка затруднительным, поскольку ее нужно получать помощью разных команд.
К командам, которые мы будем использовать, относятся команды lscpu, /proc/cpuinfo и lstopo (hwloc). С их помощью можно узнать подробную информацию о ядрах и процессорах. В следующих примерах объясняется, как следует интерпретировать результаты, выдаваемые этими командами.
1. Поставщик и модель процессора
Чтобы определить поставщика и название модели процессора, выполните с помощью команды grep поиск в файле /proc/cpuinfo.
Это процессор фирмы Intel. Затем находим имя модели, которое можно использовать для поиска точных спецификаций на сайте Intel.
Это процессор «Core 2 Quad Q8400».
2. Архитектура
С помощью команды lscpu можно узнать архитектуру процессора.
Архитектура — x86_64, что означает 64 разрядную архитектуру.
3. Частота
Частоту/скорость работы процессора можно узнать с помощью команды lscpu и в файле /proc/cpuinfo.
Поскольку большинство современных процессоров работают на более низких частотах для экономии энергии, частота, о которой сообщается, может быть ниже, чем действительная частота работы указанного процессора. Когда нагрузка увеличивается, они переключаются на более высокую частоту.
Изменение частоты можно обнаружить в файле of /proc/cpuinfo, если использовать для этого команду watch.
Запустите в терминале указанную выше команду и, пока она работает, запустите какую-нибудь задачу, которая интенсивно использует процессор, и частота должна увеличиться.
4. Количество ядер
Каждое ядро процессора является, на самом деле, независимым процессором. Несколько ядер позволяют процессору одновременно выполнять несколько команд в программе, в результате чего скорость обработки данных увеличивается.
Команда lscpu указывает «количество ядер в одном сокете».
Таким образом, в этом случае количество ядер в процессоре равно 4.
В файле /proc/cpuinfo также есть информация о количестве ядер, но ее получить немного сложнее и запутаннее.
Простой подсчет количества процессоров может дать неправильное количество.
В случае, когда используется режим hyper threading, количество процессоров, которые видит операционная система, в два раза превышает количество ядер. Но в файле /proc/cpuinfo есть поле с именем «core id», которое уникально для каждого ядра одного процессора. Подсчет этих имен позволяет получить четкое представление о количестве реальных ядер в процессоре
Несколько процессоров
Редко, но в тех случаях, если вы используете систему, в которой имеется несколько физических процессоров (да, это означает 2 или больше процессоров, установленных на материнской плате), то результаты в файле /proc/cpuinfo будут другими. В случае нескольких процессоров, «physical id» будет означать несколько значений.
Если есть более одного идентификатора физического процессора, то это означает, что в системе есть несколько физических процессоров. И в каждом процессоре вы должны посчитать ядра отдельно.
5. Технология Hyper threading
Hyper threading это технология фирмы Intel, которая позволяет одному ядру выполнять обработку так, как если бы это было два ядра. Это в определенных случаях также некоторым образом увеличивает вычислительную мощность каждого ядра.
Чтобы проверить, поддерживается ли в процессоре режим hyper-threading, необходимо сравнить два значения. Первым является фактическое количество ядер, а вторым — логическое количество.
Если количество ядер равно количеству процессоров, которые видно в ОС, то режим hyper threading отсутствует. В противном случае, т. е. если количество блоков обработки больше (в два раза больше) числа ядер, то режим hyper threading присутствует.
В качестве примера возьмем процессор Core 2 Quad Q8400
Количество процессоров, как показано в /proc/cpuinfo, равно 4
Количество «cpu cores» = 4, также, как и «siblings» = 4, а «core id» = 4
Поэтому общее число процессоров равно количеству фактических ядер. Следовательно на этом процессоре режим hyper threading отсутствует, что и подтверждается спецификациями процессора, приводимыми на сайте Intel.
Процессор с технологией hyper threading
Сведения, касающиеся hyper threading, которые присутствуют в /proc/cpuinfo или в выходных данных lscpu будут отличаться.
Обратите внимание на строку «Thread(s) per core: 2», указывающую, что в каждом ядре есть по 2 потока; ядер, в общей сложности, четыре. Таким образом, количество процессоров, которые видны в ОС, равно 8.
Теперь давайте взглянем на данные из /proc/cpuinfo.
Здесь «cpu cores» = 4 и «siblings» = 8 означают, что имеется 4 ядра и по 2 гиперпотока на ядро. Количество процессоров, как это показано в /proc/cpuinfo, также будет равно 8.
Флаг HTT в выходных данных dmidecode и флаг ht во флагах /proc/cpuinf могут давать неверную информацию, касающуюся режима hyper threading.
Для процессора Core2Quad Q8400 dmidecode и /proc/cpuinfo показывают, что флаг гиперпотоков установлен, несмотря на то, что в данном процессоре режим hyper threading недоступен.
Утилита hwloc / lstopo
Утилита hwloc является небольшой утилитой, которая сообщает о структуре процессора в виде приятной диаграммы. В диаграмме показано количество ядер, наличие режима hyper threading и объем кэш-памяти. Обо всем рассказывает одна схема.
Из приведенной выше диаграммы ясно видно, что размер кэша второго уровня L2 — 4096 KB или 4MB, количество ядер — 4, количество потоков в ядре — 1.
Процессор с технологией hyper threading
Для процессора с режимом hyper threading, выдаваемая диаграмма hwloc может выглядеть следующим образом
На диаграмме показано, что размер кэша третьего уровня L3 — 8MB, количество ядер — 4, количество потоков в ядре — 2 (т. е. режим hyper threading имеется).
Источник