ในบทความก่อนหน้านี้ เราได้รวบรวมรายการคำสั่งที่มีประโยชน์ 10 คำสั่งเพื่อรวบรวมข้อมูลระบบและฮาร์ดแวร์ใน Linux ในคู่มือนี้ เราจะจำกัดให้แคบลงจนถึง CPU/โปรเซสเซอร์ และแสดงวิธีการต่างๆ ในการดึงข้อมูลโดยละเอียดเกี่ยวกับ CPU ในเครื่องของคุณ
เพียงเพื่อให้ภาพรวมแก่คุณ เราจะสืบค้นข้อมูล เช่น สถาปัตยกรรม CPU, vendor_id, รุ่น, ชื่อรุ่น, จำนวนคอร์ CPU, ความเร็วของแต่ละคอร์ และอื่นๆ อีกมากมาย
โดยพื้นฐานแล้ว /proc/cpuinfo มีข้อมูลทั้งหมดนี้ ทุกคำสั่ง/ยูทิลิตี้อื่น ๆ จะได้รับเอาต์พุตจากไฟล์นี้
ตามที่กล่าวไว้ ด้านล่างนี้คือคำสั่ง 9 คำสั่งในการรับข้อมูลเกี่ยวกับ CPU Linux ของคุณ
1. รับข้อมูล CPU โดยใช้คำสั่ง cat
คุณสามารถดูข้อมูล CPU ของระบบของคุณได้โดยการดูเนื้อหาของ /proc/cpuinfo โดยใช้คำสั่ง cat ดังนี้:
$ cat /proc/cpuinfo
ข้อมูลซีพียูลินุกซ์
processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 69 model name : Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz stepping : 1 microcode : 0x1c cpu MHz : 1700.062 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 : 13 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 arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm epb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts bugs : bogomips : 4788.92 clflush size : 64 cache_alignment : 64 address sizes : 39 bits physical, 48 bits virtual power management: ......
เพื่อให้เจาะจงยิ่งขึ้น คุณสามารถใช้คำสั่ง grep ซึ่งเป็นเครื่องมือ CLI สำหรับค้นหาข้อมูลข้อความธรรมดาสำหรับบรรทัดที่ตรงกับนิพจน์ทั่วไป สิ่งนี้สามารถช่วยคุณส่งออกเฉพาะชื่อผู้จำหน่าย ชื่อรุ่น จำนวนโปรเซสเซอร์ จำนวนคอร์ ฯลฯ:
$ cat /proc/cpuinfo | grep 'vendor' | uniq #view vendor name $ cat /proc/cpuinfo | grep 'model name' | uniq #display model name $ cat /proc/cpuinfo | grep processor | wc -l #count the number of processing units $ cat /proc/cpuinfo | grep 'core id' #show individual cores
แนะนำให้อ่าน:วิธีใช้คำสั่ง 'cat' และ 'tac' พร้อมตัวอย่างใน Linux
2. คำสั่ง lscpu – แสดงข้อมูลสถาปัตยกรรม CPU
คำสั่ง lscpu พิมพ์ข้อมูลสถาปัตยกรรม CPU จาก sysfs และ /proc/cpuinfo ดังที่แสดงด้านล่าง:
$ lscpu
สถาปัตยกรรมซีพียูลินุกซ์
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: 69 Model name: Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz Stepping: 1 CPU MHz: 1303.687 CPU max MHz: 2700.0000 CPU min MHz: 800.0000 BogoMIPS: 4788.92 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 arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm epb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts
3. คำสั่ง cpuid – แสดง CPU x86
คำสั่ง ซีพียู ทิ้งข้อมูลทั้งหมดเกี่ยวกับ CPU ที่รวบรวมจากคำสั่ง CPUID และยังค้นหารุ่นที่แน่นอนของ CPU x86 จากข้อมูลนั้น
ตรวจสอบให้แน่ใจว่าได้ติดตั้งก่อนใช้งาน
$ sudo apt install cpuid #Debian/Ubuntu systems $ sudo yum install cpuid #RHEL/CentOS systems $ sudo dnf install cpuid #Fedora 22+
เมื่อติดตั้งแล้ว ให้รัน cpuid เพื่อรวบรวมข้อมูลเกี่ยวกับ CPU x86
$ cpuid
แสดงข้อมูล CPU x86
CPU 0: vendor_id = "GenuineIntel" version information (1/eax): processor type = primary processor (0) family = Intel Pentium Pro/II/III/Celeron/Core/Core 2/Atom, AMD Athlon/Duron, Cyrix M2, VIA C3 (6) model = 0x5 (5) stepping id = 0x1 (1) extended family = 0x0 (0) extended model = 0x4 (4) (simple synth) = Intel Mobile Core i3-4000Y / Mobile Core i5-4000Y / Mobile Core i7-4000Y / Mobile Pentium 3500U/3600U/3500Y / Mobile Celeron 2900U (Mobile U/Y) (Haswell), 22nm miscellaneous (1/ebx): process local APIC physical ID = 0x0 (0) cpu count = 0x10 (16) CLFLUSH line size = 0x8 (8) brand index = 0x0 (0) brand id = 0x00 (0): unknown feature information (1/edx): x87 FPU on chip = true virtual-8086 mode enhancement = true debugging extensions = true page size extensions = true time stamp counter = true RDMSR and WRMSR support = true physical address extensions = true ....
4. คำสั่ง dmidecode – แสดงข้อมูลฮาร์ดแวร์ Linux
dmidecode เป็นเครื่องมือสำหรับดึงข้อมูลฮาร์ดแวร์ของระบบ Linux ใดๆ โดยจะทิ้งเนื้อหาตาราง DMI (หรือที่เรียกว่า SMBIOS) ของคอมพิวเตอร์ในรูปแบบที่มนุษย์สามารถอ่านได้เพื่อการเรียกค้นที่ง่ายดาย ข้อมูลจำเพาะ SMBIOS กำหนดประเภท DMI ต่างๆ สำหรับ CPU ให้ใช้ “โปรเซสเซอร์” ดังนี้:
$ sudo dmidecode --type processor
แสดงข้อมูลฮาร์ดแวร์ Linux
# dmidecode 3.0 Getting SMBIOS data from sysfs. SMBIOS 2.7 present. Handle 0x0004, DMI type 4, 42 bytes Processor Information Socket Designation: U3E1 Type: Central Processor Family: Core i5 Manufacturer: Intel(R) Corporation ID: 51 06 04 00 FF FB EB BF Signature: Type 0, Family 6, Model 69, Stepping 1 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) .....
5. เครื่องมือ Inxi – แสดงข้อมูลระบบ Linux
Inxi เป็นสคริปต์ข้อมูลระบบบรรทัดคำสั่งที่มีประสิทธิภาพสำหรับทั้งคอนโซลและ IRC (Internet Relay Chat) คุณสามารถใช้มันเพื่อดึงข้อมูลฮาร์ดแวร์ได้ทันที
คุณสามารถติดตั้งได้ดังนี้:
$ sudo apt install inxi #Debian/Ubuntu systems $ sudo yum install inxi #RHEL/CentOS systems $ sudo dnf install inxi #Fedora 22+
หากต้องการแสดงข้อมูล CPU ที่สมบูรณ์ รวมถึงความเร็วสัญญาณนาฬิกาของ CPU และความเร็วสูงสุดของ CPU (ถ้ามี) ให้ใช้ -C ตั้งค่าสถานะดังนี้:
$ inxi -C
พิมพ์ข้อมูลระบบ Linux
CPU: Dual core Intel Core i5-4210U (-HT-MCP-) cache: 3072 KB clock speeds: max: 2700 MHz 1: 1958 MHz 2: 1993 MHz 3: 1775 MHz 4: 1714 MHz
6. เครื่องมือ lshw – รายการการกำหนดค่าฮาร์ดแวร์
lshw เป็นเครื่องมือขั้นต่ำสำหรับการรวบรวมข้อมูลเชิงลึกเกี่ยวกับการกำหนดค่าฮาร์ดแวร์ของคอมพิวเตอร์ คุณสามารถใช้ -C ตัวเลือกเพื่อเลือกคลาสฮาร์ดแวร์ CPU ในกรณีนี้:
$ sudo lshw -C CPU
พิมพ์การกำหนดค่าฮาร์ดแวร์ Linux
*-cpu description: CPU product: Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz vendor: Intel Corp. physical id: 4 bus info: cpu@0 version: Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz serial: To Be Filled By O.E.M. slot: U3E1 size: 2626MHz capacity: 2700MHz 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 arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm epb tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt dtherm ida arat pln pts cpufreq configuration: cores=2 enabledcores=2 threads=4
7. hardinfo – แสดงข้อมูลฮาร์ดแวร์ในหน้าต่าง GTK+
ฮาร์ดข้อมูล แสดงข้อมูลฮาร์ดแวร์ในหน้าต่าง GTK+ คุณสามารถติดตั้งได้ดังนี้:
$ sudo apt install hardinfo #Debian/Ubuntu systems $ sudo yum install hardinfo #RHEL/CentOS systems $ sudo dnf install hardinfo #Fedora 22+
เมื่อคุณติดตั้งแล้ว ให้พิมพ์:
$ hardinfo
ข้อมูลระบบ Linux นอกจากนี้ยังช่วยให้คุณสร้างรายงานข้อมูลฮาร์ดแวร์ระบบได้โดยคลิกที่ “สร้างรายงาน ปุ่ม” จากอินเทอร์เฟซด้านล่าง คลิก "สร้าง ” เพื่อดำเนินการต่อ โปรดทราบว่าคุณสามารถเลือกหมวดหมู่ข้อมูลฮาร์ดแวร์ที่จะสร้างได้
สร้างรายงานข้อมูลระบบ เมื่อคุณสร้างรายงานในรูปแบบ html แล้ว คุณจะสามารถดูได้จากเว็บเบราว์เซอร์ดังที่แสดงด้านล่าง
ข้อมูลรายละเอียดระบบ Linux 8. hwinfo – แสดงข้อมูลฮาร์ดแวร์ปัจจุบัน
ข้อมูล ใช้เพื่อดึงข้อมูลเกี่ยวกับฮาร์ดแวร์ที่มีอยู่ในระบบ Linux หากต้องการแสดงข้อมูลเกี่ยวกับ CPU ของคุณ ให้ใช้ --cpu ป>
$ hwinfo --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.69.1 "Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz" 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,arch_perfmon,pebs,bts,rep_good,nopl,xtopology,nonstop_tsc,aperfmperf,eagerfpu,pni,pclmulqdq,dtes64,monitor,ds_cpl,vmx,est,tm2,ssse3,sdbg,fma,cx16,xtpr,pdcm,pcid,sse4_1,sse4_2,movbe,popcnt,tsc_deadline_timer,aes,xsave,avx,f16c,rdrand,lahf_lm,abm,epb,tpr_shadow,vnmi,flexpriority,ept,vpid,fsgsbase,tsc_adjust,bmi1,avx2,smep,bmi2,erms,invpcid,xsaveopt,dtherm,ida,arat,pln,pts Clock: 2080 MHz BogoMips: 4788.92 Cache: 3072 kb Units/Processor: 16 Config Status: cfg=new, avail=yes, need=no, active=unknown ....
9. nproc – พิมพ์จำนวนหน่วยประมวลผล
nproc คำสั่งใช้เพื่อแสดงจำนวนหน่วยประมวลผลที่มีอยู่ในคอมพิวเตอร์ของคุณ:
$ nproc
สำหรับข้อมูลการใช้งานและตัวเลือกเพิ่มเติม โปรดอ่าน man page ของคำสั่งเหล่านี้ดังนี้:
$ man commandname
นอกจากนี้ โปรดดู:
- Cpustat – ตรวจสอบการใช้งาน CPU โดยการรันกระบวนการใน Linux
- CoreFreq – เครื่องมือตรวจสอบ CPU อันทรงพลังสำหรับระบบ Linux
- ค้นหากระบวนการที่ทำงานสูงสุดตามหน่วยความจำและการใช้งาน CPU สูงสุดใน Linux
- วิธีทดสอบโหลด CPU และความเครียดที่สูงบน Linux โดยใช้เครื่องมือ 'Stress-ng'
แค่นั้นแหละ! คุณสามารถแบ่งปันวิธีเพิ่มเติมในการดึงข้อมูล CPU ใน Linux ให้เราทราบผ่านแบบฟอร์มคำติชมด้านล่าง