未加星标

5 Ways to Check CPU Info in Linux

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二04 | 时间 2019 | 作者 红领巾 ] 0人收藏点击收藏

Here are multiple ways you can get CPU information in linux command line. You can get processor information like the number of real cores, logical cores, hyperthreading, CPU frequency etc.

There are a number of ways you can get information about the processor on your Linux system. I’ll show you my favorite tool for this task along with a few additional ways to check SPUs in Linux.

Get CPU info with lscpu command
5 Ways to Check CPU Info in Linux
Image Credit: Freepik

This is the simplest command that shows the CPU information in a simple and concise output.

You can see the architecture of your system, number of processors, vendor information, cache information, processor speed etc.

It’s easier to remember as well because it is similar to thels command. You can think of it as ‘list cpu’.

Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 2 Core(s) per socket: 2 Socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 142 Model name: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz Stepping: 9 CPU MHz: 900.054 CPU max MHz: 3100.0000 CPU min MHz: 400.0000 BogoMIPS: 5424.00 Virtualization: VT-x L1d cache: 32K L1i cache: 32K L2 cache: 256K L3 cache: 3072K NUMA node0 CPU(s): 0-3 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp flush_l1d

Well… that’s the processor information for my system and it should look somewhat similar for your Linux system as well.

As you can see, the most important information is that my system has Intel i5-7200U processor. I can go and search on the web for this model number to get more information.

But what does other fields in the output mean? What information do you really have about the processor here? Let me explain it to you. The information is too technical so you should have some basic understanding of the terms here.

lscpu command output explanation

The architecture for my system is 64-bit. Which means it’s a 64-bit processor.

The CPU op-mods are 32 bit and 64 bit meaning that it can operate both as a 32-bit and 64-bit processor. In other words, you can install both 32-bit and 64-bit operating systems on it.

Byte order is Little Endian. Which means that bytes are arranged as per Little Endian order .

The next 4 lines tells you about the number of processors, CPUs/cores and threads. I would suggest reading this article to understand a bit about processors . This picture from Intel also helps in visualizing what socket, CPU, core, threads mean.


5 Ways to Check CPU Info in Linux
Image Source: Intel

We have to go in the reverse order here. My system has 1 socket here which means it has one single chip for the CPUs.

READ Monitoring and Testing the Health of SSD in Linux

That one socket has 2 cores. It means that the single chip has two physical CPUs on it. This tells you the number of real cores i.e. the actual physical CPUs.

And as you can see, each core has two threads. Threads are basically logical CPUs. The threads share physical execution resources of the physical core but the operating system sees them as separate cores. Read more on hyper- threading here .

In short, my system has one chip that contains two physical CPUs and each CPU is divided into two logical CPUs. And thus my dual core system is seen as having 4 CPUs by the operating system.

There is one NUMA node , the vendor is Intel and the CPU family is 6.

The CPU model number is 142 (not relevant in my opinion) and the model name is Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz (most important info).

Stepping is a number used by Intel to identify what level of design change a microprocessor was built to.

The current clock speed of my CPU is 900.054 MHz whereas its maximum capacity is 3100 MHz and 400 MHz.

BogoMIPS is “the number of million times per second a processor can do absolutely nothing”.

Virtualization is VT-x and is used to “help accelerate virtual machines created in VirtualBox, VMware, Hyper-V, and other apps”.

The next four entries are about cache . It has L1D (data cache) of 32K, L1I (instruction cache) of 32K, L2 cache of 256K and L3 cache of 3072K. Read this wiki page to get quick info on CPU caches .

Next is NUMA node for each CPU (both logical and physical CPUs).

The last line is the list of feature flags that are manufacturer specific. You may read more about them here .

This picture summarizes the most important processor information you get from the lscpu command.


5 Ways to Check CPU Info in Linux
Essential CPU information in Linux

In my opinion, lscpu command is more than enough to give you all the information you need.

Other commands to check CPU information in Linux

There are other ways to get CPU info in Linux command line. Let me show them one by one. However, I won’t go in detail to explain their output.

1. Check the content of /proc/cpuinfo

proc is a special directory in Linux. It’s actually a virtual filesystem that contains runtime system information such as system memory, devices mounted, hardware configuration etc.

If you want CPU information, you can read the content of the cpuinfo file in proc directory.

You would note that cpuinfo file has detailed information on each core of the processor.

For example, the first core of my CPU has the following information:

processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 142 model name : Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz stepping : 9 microcode : 0x8e cpu MHz : 800.026 cache size : 3072 KB physical id : 0 siblings : 4 core id : 0 cpu cores : 2 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 22 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp flush_l1d bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass l1tf bogomips : 5424.00 clflush size : 64 cache_alignment : 64 address sizes : 39 bits physical, 48 bits virtual power management:

If you just want to number of CPU cores (including both physical and logical ones), you canuse the grep command withthe wc command .

cat /proc/cpuinfo | grep processor | wc -l 4 2. Use lshw command

lshw stands for ‘list hardware’. Quite obviously, it means to list the hardware information.

READ How to Create a Sudo User on Ubuntu and Debian

Since the lshw command provides information about all the hardware on your system, it will be difficult to find exactly what you are looking for.

This is why lshw command provides option to narrow down your intended search.

To show only the processor information, you can use the lshw command in the following way:

sudo lshw -class CPU

This will show an output like this:

*-cpu description: CPU product: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz vendor: Intel Corp. physical id: 3f bus info: cpu@0 version: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz serial: To Be Filled By O.E.M. slot: U3E1 size: 2964MHz capacity: 3100MHz width: 64 bits clock: 100MHz capabilities: x86-64 fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp flush_l1d cpufreq configuration: cores=2 enabledcores=2 threads=4 3. Use hwinfo

hwinfo is another command line tool to get hardware information of your Linux system.

You probably have to install hwinfo tool first. On Debian and Ubuntu, you can use the apt command to install it.

sudo apt install hwinfo

Once installed, you can get the CPU details in this way:

hwinfo --cpu

You’ll see an output similar to this for each core of the CPU:

01: None 00.0: 10103 CPU [Created at cpu.460] Unique ID: rdCR.j8NaKXDZtZ6 Hardware Class: cpu Arch: X86-64 Vendor: "GenuineIntel" Model: 6.142.9 "Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz" Features: fpu,vme,de,pse,tsc,msr,pae,mce,cx8,apic,sep,mtrr,pge,mca,cmov,pat,pse36,clflush,dts,acpi,mmx,fxsr,sse,sse2,ss,ht,tm,pbe,syscall,nx,pdpe1gb,rdtscp,lm,constant_tsc,art,arch_perfmon,pebs,bts,rep_good,nopl,xtopology,nonstop_tsc,cpuid,aperfmperf,tsc_known_freq,pni,pclmulqdq,dtes64,monitor,ds_cpl,vmx,est,tm2,ssse3,sdbg,fma,cx16,xtpr,pdcm,pcid,sse4_1,sse4_2,x2apic,movbe,popcnt,tsc_deadline_timer,aes,xsave,avx,f16c,rdrand,lahf_lm,abm,3dnowprefetch,cpuid_fault,epb,invpcid_single,pti,ssbd,ibrs,ibpb,stibp,tpr_shadow,vnmi,flexpriority,ept,vpid,fsgsbase,tsc_adjust,bmi1,avx2,smep,bmi2,erms,invpcid,mpx,rdseed,adx,smap,clflushopt,intel_pt,xsaveopt,xsavec,xgetbv1,xsaves,dtherm,ida,arat,pln,pts,hwp,hwp_notify,hwp_act_window,hwp_epp,flush_l1d Clock: 3050 MHz BogoMips: 5424.00 Cache: 3072 kb Units/Processor: 16 Config Status: cfg=new, avail=yes, need=no, active=unknown 4. dmidecode Command

dmidecode is another command to retrieve the hardware information of your Linus system. You can use it to get only the processor information.

sudo dmidecode --type processor

This command needssudo access as well. You’ll see an output like this:

dmidecode 3.1 Getting SMBIOS data from sysfs. SMBIOS 3.0.0 present. Handle 0x003F, DMI type 4, 48 bytes Processor Information Socket Designation: U3E1 Type: Central Processor Family: Core i5 Manufacturer: Intel(R) Corporation ID: E9 06 08 00 FF FB EB BF Signature: Type 0, Family 6, Model 142, Stepping 9 Flags: FPU (Floating-point unit on-chip) VME (Virtual mode extension) DE (Debugging extension) PSE (Page size extension) TSC (Time stamp counter) MSR (Model specific registers) PAE (Physical address extension) MCE (Machine check exception) CX8 (CMPXCHG8 instruction supported) APIC (On-chip APIC hardware supported) SEP (Fast system call) MTRR (Memory type range registers) PGE (Page global enable) MCA (Machine check architecture) CMOV (Conditional move instruction supported) PAT (Page at

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

分页:12
转载请注明
本文标题:5 Ways to Check CPU Info in Linux
本站链接:https://www.codesec.net/view/628571.html


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(192)