웹사이트 검색

Linux에서 CPU 정보를 얻는 데 유용한 9가지 명령


이전 기사에서는 Linux에서 시스템 및 하드웨어 정보를 수집하는 데 유용한 10가지 명령 목록을 정리했습니다. 이 가이드에서는 CPU/프로세서로 범위를 좁히고 컴퓨터 CPU에 대한 세부 정보를 추출하는 다양한 방법을 보여줍니다.

개요를 제공하기 위해 CPU 아키텍처, 공급업체_ID, 모델, 모델 이름, CPU 코어 수, 각 코어 속도 등과 같은 정보를 쿼리합니다.
기본적으로 /proc/cpuinfo에는 이 모든 정보가 포함되어 있으며 다른 모든 명령/유틸리티는 이 파일에서 출력을 가져옵니다.

다음은 Linux CPU에 대한 정보를 얻기 위한 9가지 명령입니다.

1. cat 명령을 사용하여 CPU 정보 가져오기

다음과 같이 cat 명령을 사용하여 /proc/cpuinfo 파일의 내용을 보면 시스템 CPU 정보를 간단히 볼 수 있습니다.

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:
......

좀 더 구체적으로 알아보려면 일반 텍스트 데이터에서 정규식과 일치하는 줄을 검색하는 CLI 도구인 grep 명령을 사용할 수 있습니다. 이렇게 하면 공급업체 이름, 모델 이름, 프로세서 수, 코어 수 등만 출력하는 데 도움이 될 수 있습니다.

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	

권장 읽기: Linux에서 예시와 함께 'cat' 및 'tac' 명령을 사용하는 방법

2. lscpu 명령 – CPU 아키텍처 정보 표시

lscpu 명령은 아래와 같이 sysfs/proc/cpuinfo에서 CPU 아키텍처 정보를 인쇄합니다.

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 명령 – x86 CPU 표시

cpuid 명령은 CPUID 명령에서 수집된 CPU에 대한 전체 정보를 덤프하고 해당 정보에서 x86 CPU의 정확한 모델도 검색합니다.

실행하기 전에 반드시 설치하세요.

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

설치가 완료되면 cpuid를 실행하여 x86 CPU에 관한 정보를 수집합니다.

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 명령 – Linux 하드웨어 정보 표시

dmidecode는 모든 Linux 시스템의 하드웨어 정보를 검색하는 도구입니다. 쉽게 검색할 수 있도록 컴퓨터의 DMI(일명 SMBIOS) 테이블 내용을 사람이 읽을 수 있는 형식으로 덤프합니다. SMBIOS 사양은 CPU에 대해 다양한 DMI 유형을 정의하며 다음과 같이 "프로세서"를 사용합니다.

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는 콘솔과 IRC(인터넷 릴레이 채팅) 모두를 위한 강력한 명령줄 시스템 정보 스크립트입니다. 이를 사용하여 하드웨어 정보를 즉시 검색할 수 있습니다.

다음과 같이 설치할 수 있습니다.

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 도구 - 하드웨어 구성 나열

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: 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+ 창에 하드웨어 정보 표시

hardinfo는 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 – 현재 하드웨어 정보 표시

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 commandname

또한 다음 사항도 확인하세요.

  1. Cpustat – Linux에서 프로세스를 실행하여 CPU 사용률을 모니터링합니다.
  2. CoreFreq – Linux 시스템을 위한 강력한 CPU 모니터링 도구
  3. Linux에서 메모리 및 CPU 사용량이 가장 높은 상위 실행 프로세스 찾기
  4. 'Stress-ng' 도구를 사용하여 Linux에서 높은 CPU 로드 및 스트레스 테스트를 수행하는 방법

지금은 그게 다야! 아래 피드백 양식을 통해 Linux에서 CPU 정보를 추출하는 추가 방법을 공유하실 수 있습니다.