9 ຄຳ ສັ່ງທີ່ມີປະໂຫຍດເພື່ອໃຫ້ໄດ້ຂໍ້ມູນກ່ຽວກັບ CPU ໃນ Linux


ໃນບົດຂຽນກ່ອນ ໜ້າ ນີ້, ພວກເຮົາໄດ້ລວມເອົາ 10 ຄຳ ສັ່ງທີ່ມີປະໂຫຍດເພື່ອເກັບ ກຳ ຂໍ້ມູນລະບົບແລະຮາດແວໃນ Linux. ໃນຄູ່ມືນີ້, ພວກເຮົາຈະແຄບລົງກັບ CPU/ໂປເຊດເຊີ, ແລະສະແດງວິທີການຕ່າງໆໃນການສະກັດຂໍ້ມູນລາຍລະອຽດກ່ຽວກັບ CPU ຂອງເຄື່ອງຂອງທ່ານ.

ພຽງແຕ່ໃຫ້ທ່ານເບິ່ງພາບລວມ, ພວກເຮົາຈະສອບຖາມຂໍ້ມູນຕ່າງໆເຊັ່ນ: ສະຖາປັດຕະຍະ ກຳ CPU, ຜູ້ ຈຳ ໜ່າຍ_id, ຮູບແບບ, ຊື່ຕົວແບບ, ຈຳ ນວນແກນ CPU, ຄວາມໄວຂອງແຕ່ລະຫຼັກ, ແລະອີກຫລາຍໆຢ່າງ.
ສິ່ງທີ່ ສຳ ຄັນ, the/proc/cpuinfo ມີຂໍ້ມູນທັງ ໝົດ ນີ້, ທຸກໆ ຄຳ ສັ່ງ/ສິ່ງ ອຳ ນວຍຄວາມສະດວກອື່ນໆໄດ້ຮັບຜົນຜະລິດຈາກເອກະສານນີ້.

ດ້ວຍສິ່ງທີ່ກ່າວມາ, ຂ້າງລຸ່ມນີ້ແມ່ນ ຄຳ ສັ່ງ 9 ຂໍ້ ສຳ ລັບການໄດ້ຮັບຂໍ້ມູນກ່ຽວກັບ CPU Linux ຂອງທ່ານ.

1. ຮັບຂໍ້ມູນ CPU ໂດຍໃຊ້ cat Command

ທ່ານພຽງແຕ່ສາມາດເບິ່ງຂໍ້ມູນຂອງ CPU ລະບົບຂອງທ່ານໂດຍການເບິ່ງເນື້ອໃນຂອງເອກະສານ/proc/cpuinfo ໂດຍການຊ່ວຍເຫຼືອຂອງ ຄຳ ສັ່ງແມວດັ່ງຕໍ່ໄປນີ້:

$ 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	

2. lscpu Command - ສະແດງຂໍ້ມູນສະຖາປັດຕະຍະ ກຳ 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 Command - ສະແດງ x86 CPU

CPU cpuid ສັ່ງຄົບຖ້ວນຂໍ້ມູນກ່ຽວກັບ CPU ທີ່ເກັບມາຈາກ ຄຳ ແນະ ນຳ ຂອງ CPUID, ແລະຍັງຄົ້ນພົບແບບ ຈຳ ລອງຂອງ x86 CPU (s) ຈາກຂໍ້ມູນນັ້ນ.

ໃຫ້ແນ່ໃຈວ່າຕິດຕັ້ງມັນກ່ອນທີ່ຈະເຮັດວຽກ.

$ 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 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 Command - ສະແດງຂໍ້ມູນຮາດແວ Linux

dmidecode ແມ່ນເຄື່ອງມື ສຳ ລັບການດຶງເອົາຂໍ້ມູນຮາດແວຂອງລະບົບ Linux ໃດໆ. ມັນຖີ້ມເນື້ອໃນຕາຕະລາງຂອງ DMI (a.k.a SMBIOS) ຂອງຄອມພິວເຕີ້ໃນຮູບແບບທີ່ສາມາດອ່ານໄດ້ຂອງມະນຸດເພື່ອການດຶງຂໍ້ມູນໄດ້ງ່າຍ. ຂໍ້ມູນສະເພາະຂອງ SMBIOS ໄດ້ ກຳ ນົດປະເພດ DMI ຕ່າງໆ, ສຳ ລັບ CPU, ໃຫ້ໃຊ້ "ໂປເຊດເຊີ" ດັ່ງຕໍ່ໄປນີ້:

$ sudo dmidecode --type processor
# 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 ແມ່ນສະຄິບຂໍ້ມູນຂ່າວສານທີ່ມີລະບົບສາຍທີ່ມີປະສິດທິພາບ ສຳ ລັບທັງ console ແລະ 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
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 Tool - ລາຍຊື່ການຕັ້ງຄ່າ Hardware

lshw ແມ່ນເຄື່ອງມື ໜ້ອຍ ທີ່ສຸດ ສຳ ລັບການລວບລວມຂໍ້ມູນທີ່ເລິກເຊິ່ງກ່ຽວກັບການຕັ້ງຄ່າຮາດແວຂອງຄອມພິວເຕີ້. ທ່ານສາມາດໃຊ້ຕົວເລືອກ -C ເພື່ອເລືອກຊັ້ນຮາດແວ, CPU ໃນກໍລະນີນີ້:

$ sudo lshw -C CPU
*-cpu                   
       description: CPU
       product: Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz
       vendor: Intel Corp.
       physical id: 4
       bus info: [email 
       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 - ສະແດງຂໍ້ມູນ Hardware ໃນ GTK + Window

hardinfo ສະແດງຂໍ້ມູນກ່ຽວກັບ Hardware ຢູ່ໃນປ່ອງຢ້ຽມ GTK +, ທ່ານສາມາດຕິດຕັ້ງມັນໄດ້ດັ່ງຕໍ່ໄປນີ້:

$ sudo apt install hardinfo 	#Debian/Ubuntu systems
$ sudo yum install hardinfo	#RHEL/CentOS systems 
$ sudo dnf install hardinfo	#Fedora 22+ 

ເມື່ອທ່ານໄດ້ຕິດຕັ້ງມັນແລ້ວ, ໃຫ້ພິມ:

$ hardinfo 

ມັນຍັງຊ່ວຍໃຫ້ທ່ານສາມາດສ້າງລາຍງານຂໍ້ມູນກ່ຽວກັບຮາດແວຂອງລະບົບໄດ້ໂດຍການກົດປຸ່ມ“ ສ້າງລາຍງານ”. ຈາກອິນເຕີເຟດດ້ານລຸ່ມ, ກົດທີ່ "ສ້າງ" ເພື່ອ ດຳ ເນີນການ. ໃຫ້ສັງເກດວ່າທ່ານສາມາດເລືອກປະເພດຂໍ້ມູນກ່ຽວກັບຮາດແວທີ່ຈະຜະລິດອອກມາ.

ເມື່ອທ່ານໄດ້ສ້າງບົດລາຍງານໃນຮູບແບບ html ແລ້ວ, ທ່ານສາມາດເບິ່ງມັນຈາກເວັບບຼາວເຊີດັ່ງທີ່ສະແດງຢູ່ດ້ານລຸ່ມ.

8. hwinfo - ສະແດງຂໍ້ມູນ Hardware Present

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 ຂອງ ຄຳ ສັ່ງດັ່ງຕໍ່ໄປນີ້:

$ man commandname

ນອກຈາກນີ້, ກວດເບິ່ງ:

<

  • Cpustat - ຕິດຕາມກວດກາການ ນຳ ໃຊ້ CPU ໂດຍການ ດຳ ເນີນຂັ້ນຕອນໃນ Linux
  • CoreFreq - ເຄື່ອງມືກວດສອບ CPU ທີ່ມີປະສິດທິພາບ ສຳ ລັບລະບົບ Linux
  • ຊອກຫາຂັ້ນຕອນການແລ່ນທີ່ສຸດໂດຍຄວາມຊົງ ຈຳ ສູງສຸດແລະການ ນຳ ໃຊ້ CPU ໃນ Linux
  • ວິທີການທົດສອບການໂຫຼດແລະຄວາມກົດດັນຂອງ CPU ສູງໃນ Linux ໂດຍໃຊ້ເຄື່ອງມື ‘Stress-ng’
  • ນັ້ນແມ່ນ ສຳ ລັບດຽວນີ້! ທ່ານສາມາດແບ່ງປັນກັບພວກເຮົາວິທີການເພີ່ມເຕີມໃນການສະກັດເອົາຂໍ້ມູນ CPU ໃນ Linux ຜ່ານແບບຟອມ ຄຳ ຄິດເຫັນດ້ານລຸ່ມ.