- How to Check Processor and CPU Details on Linux – Command Examples
- Processor/Cpu details
- 1. Vendor and model of the processor
- 2. Architecture
- 3. Frequency
- 4. Number of cores
- 5. Hyper threading
- Hwloc / lstopo
- Conclusion
- 10 thoughts on “ How to Check Processor and CPU Details on Linux – Command Examples ”
- 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 ”
- Linux Find Out CPU Architecture Information
- Related media
How to Check Processor and CPU Details on Linux – Command Examples
Processor/Cpu details
The details about the processor that we shall be talking about include, number of cores, availability of hyper threading, architecture, cache size etc.
To find these details about the cpu on your system can be a bit difficult because the way different commands check them.
The commands that we are going to use include lscpu, /proc/cpuinfo and lstopo (hwloc).
These commands show detailed information about the cpu cores/processing units.
The examples following next would explain how to interpret the output of these commands.
1. Vendor and model of the processor
To find the vendor and model name of the processor, search the /proc/cpuinfo file with the grep command.
Its an Intel processor. Next find the model name that can be used to lookup the exact specifications online on Intel’s website.
Its a «Core 2 Quad Q8400» processor.
2. Architecture
The lscpu commands reports the architecture.
The architecture is x86_64 which is 64 bit.
3. Frequency
The frequency/speed of the processor is reported by both lscpu and /proc/cpuinfo.
The change of frequency can be seen by monitoring the output of /proc/cpuinfo using watch.
Run the above command in a terminal and while it is running, launch some cpu intensive task in parallel and the frequency would increase.
4. Number of cores
Each core on the processor is an actual independant cpu or processing unit. Multiple cores enable the processor to execute multiple program instructions in parallel, thereby increasing the processing speed.
The lscpu command indicates the «cores per socket».
So in this case the number of cores on the processor is 4.
The /proc/cpuinfo file also indicates the number of cores, but it can be bit tricky and confusing.
Simply counting the number of processors may give wrong numbers.
In case of hyper threaded processors, the number of processors that the operating system sees is twice the number of cores.
However /proc/cpuinfo has a field named ‘core id’ which is a unique id for each core in a single processor. Counting the core id would give a clear indication of the number of actual cores on the processor
Rare, but in case you are on a system that has multiple physical processors (yes, it means 2 or more processors fitted on the motherboard), then the results of /proc/cpuinfo would be different. In case of multiple processors, the ‘physical id’ would indicate multiple values.
If there are more than 1 physical ids, then there are multiple physical processors on the system. And you have to count the cores on each processor separately.
5. Hyper threading
Hyper threading is an Intel technology that allows individual cores to perform like 2 logical processing units. This, in a way increases the processing power of each core in a limited manner.
To check whether the processor has hyper-threading, 2 different values have to be compared. First is the number of actual cores, and second is the number of logical processing units.
If the number of cores is equal to the number of processing units as seen by the OS, then NO hyper threading. Otherwise if the number of processing units is greater/twice the number of cores, then YES hyper threading.
Take this example of a Core 2 Quad Q8400 processor
Number of processors as shown by /proc/cpuinfo is 4
Number of ‘cpu cores’ = 4 as well as ‘siblings’ = 4 and unique ‘core id’ = 4
Therefore total number of processing units = number of actual cores. So there is no hyper threading on this processor, and the same can be confirmed from the specs of the processor on Intel’s website.
Incase of hyper threading being present the output of /proc/cpuinfo or lscpu would be different.
Note the «Thread(s) per core: 2» which indicate that there are 2 threads per core, with a total of 4 cores. So the number of processing units seen by the OS is 8.
Now lets take a look at the output of /proc/cpuinfo.
The ‘cpu cores’ = 4 and siblings = 8 which means there are 4 cores and 2 hyperthreads per core. Number of processors as shown by /proc/cpuinfo would also be 8.
For the Core2Quad Q8400 processor, both dmidecode and /proc/cpuinfo show the hyperthreading flag enabled, inspite of hyper threading not being available on the processor.
Hwloc / lstopo
Hwloc (Portable hardware locality) is a small utility that reports the structure of the processor in a neat visual diagram. The diagram shows the number of cores, hyperthreads and cache size. A single diagram tells it all.
The above diagram clearly shows —
Total L2 Cache — 4096 KB — 4MB
Total Cores — 4
Processing unit per core — 1
Hyper-threaded processor
For a hyperthreaded processor, the hwloc output diagram could look like this
The diagram indicates
Total L3 Cache — 8MB
Total Cores — 4
Processing units per Core — 2 [hyper threading]
Conclusion
To learn more about commands for checking CPU information on Linux check this post:
9 Commands to Check CPU Information on Linux
If you have any feedback or questions 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] .
10 thoughts on “ How to Check Processor and CPU Details on Linux – Command Examples ”
If you are looking for physical CPU count /proc/cpuinfo is confusing . It gives the number of threads .
To get physical CPU count .
]# dmidecode -t 4 | egrep -i “Designation|Intel|core|thread”
Socket Designation: CPU1
Manufacturer: Intel
HTT (Multi-threading)
Version: Intel(R) Xeon(R) CPU L5640 @ 2.27GHz
Core Count: 6
Core Enabled: 6
Thread Count: 12
Socket Designation: CPU2
Manufacturer: Intel
HTT (Multi-threading)
Version: Intel(R) Xeon(R) CPU L5640 @ 2.27GHz
Core Count: 6
Core Enabled: 6
Thread Count: 12
The same server if i give
]# cat /proc/cpuinfo | egrep processor | wc -l
24
So its means i have a 24 threads system , so dont rely on cpuinfo .
Useless use of cat.
cat /proc/cpuinfo | grep processor
grep processor /proc/cpuinfo
In the last example you have hwloc as the command to run. You meant to have $ lstopo.
Источник
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.
Источник
Linux Find Out CPU Architecture Information
Open a terminal and type the following command:
$ less /proc/cpuinfo
Sample outputs:
Fig.01: /etc/cpuinfo is a collection of CPU and system architecture dependent item on Linux
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
- Architecture: The architecture of your CPU. In this case, it is x86_64 (AMD64).
- CPU : The logical CPU number of a CPU.
- CACHE : Information about how caches are shared between CPUs i.e. L1/L2/L3 cpus.
Related media
You can see the lscpu command output using the following video:
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Category | List of Unix and Linux commands |
---|---|
Documentation | help • mandb • man • pinfo |
Disk space analyzers | df • duf • ncdu • pydf |
File Management | cat • cp • less • mkdir • more • tree |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Linux Desktop Apps | Skype • Spotify • VLC 3 |
Modern utilities | bat • exa |
Network Utilities | NetHogs • dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop |
Searching | ag • grep • whereis • which |
Shell builtins | compgen • echo • printf |
Text processing | cut • rev |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
Comments on this entry are closed.
is this file dynamically generated or cached ?
can we edit this file ?
No you cannot edit this file.
is “lscpu” available for redhat and its variants ? It is really a cool command/tool to have with all Linux System Administrator.
If [lscpu] does not exist for your distribution, you can always create a shell alias to create a shortcut of the following command
alias lscpu=”/bin/cat /proc/cpuinfo|/bin/grep -E ‘processor|model name|cache size|core|sibling|physical’”
Then afterwards, you can use this command anywhere.
Just add it to your personal Bash customization startup file, located into your home directory, namely [
/.bashrc ] or sometimes specific included file [
Useless use of cat.
lscpu command available on latest version of Ubuntu, Debian, RHEL 6 and above.
“Useless use of cat?”
Yeah, quite right, of course.
alias lscpu=’/bin/grep -E “processor|model name|cache size|core|sibling|physical” /proc/cpuinfo’
This will do the trick!
Appreciate your comment, but a vanilla grepping of /proc/cpuinfo with specified fields are not enough to get lscpu like detailed output. Its lacking of “Number of Physical CPU, Core per CPU, Threads in each Core, L1/D1/D3 Cache size, CPU Mode, Virtualization Technology Used, NUMA Node ID”. Of course bit sophisticated grepping/sorting/uniq on /proc/cpuinfo with generate the required output, still precompiled version of lscpu will be a great add-on for systemadmins.
Really helpful commands.
thankz for the article…i was searching for this…
how we can check processor types like (dual core ,quadcore ) in linux mechine
suppose my cpuimfo out put like Intel Xeon(R) CPUX5355 @ 2.66GHz how i know this is dualcore or quad core processor ?
as a c++ guy, I’m trying to get my barecomputer_o (Vettrasoft Z Directory object)
working on Debian linux – is there a [c function] OS API to get CPU info? I can
fork()/exec() or do system(“lscpu > /tmp/somefile”) and do a bunch fo grunt
Quick&Dirty hacking, not elegant
In microsoft-land, I use a combo of __cpuid (CPUInfo, 0); and embedded assembler,
eg,
Its cant Editable Proc will get created while the system boots every time in RAM , U can create it manually if your Root User
The terminal scares the heck out of me but this command is useful a very simple.
Thank you very much.
Источник