리눅스에서 CPU 정보를 얻는 유용한 명령어 9가지

이전 글에서는 Linux에서 시스템 및 하드웨어 정보를 수집하는 데 유용한 10가지 명령어 목록을 모았습니다. 이 가이드에서는 CPU/프로세서로 좁혀서 여러분의 컴퓨터 CPU에 대한 상세 정보를 추출하는 다양한 방법을 보여드리겠습니다.

간단히 설명하자면, CPU 아키텍처, vendor_id, 모델, 모델 이름, CPU 코어 수, 각 코어의 속도 등과 같은 정보를 조회할 것입니다.
기본적으로, /proc/cpuinfo에는 이 모든 정보가 포함되어 있으며, 다른 모든 명령어/유틸리티는 이 파일에서 출력을 받습니다.

그렇다면, 아래는 Linux CPU에 대한 정보를 얻는 데 사용할 수 있는 9가지 명령어입니다.

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

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

$ cat /proc/cpuinfo
Linux CPU Information
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 명령어를 사용할 수 있습니다. 이를 통해 vendor 이름, 모델 이름, 프로세서 수, 코어 수 등을 출력할 수 있습니다.

$ 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’ 명령어 사용 방법과 예제

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

명령어 lscpu는 아래와 같이 sysfs/proc/cpuinfo에서 CPU 아키텍처 정보를 출력합니다:

$ lscpu
Linux CPU Architecture
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+ 

설치한 후, x86 CPU에 대한 정보 수집을 위해 cpuid를 실행하십시오.

$ cpuid
Shows x86 CPU Information
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 명령어 – 리눅스 하드웨어 정보 표시

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

$ sudo dmidecode --type processor
Shows Linux Hardware Information
# 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 도구 – 리눅스 시스템 정보 표시

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
Print Linux System Information
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는 컴퓨터의 하드웨어 구성에 대한 깊은 정보를 수집하는 데 사용되는 최소한의 도구입니다. 이 경우 CPU를 선택하려면 -C 옵션을 사용할 수 있습니다:

$ sudo lshw -C CPU
Print Linux Hardware Configuration
*-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 
Linux System Information

또한 “보고서 생성” 버튼을 클릭하여 시스템 하드웨어 정보 보고서를 생성할 수 있습니다. 아래 인터페이스에서 “생성”을 클릭하여 진행하십시오. 생성할 하드웨어 정보 카테고리를 선택할 수 있음을 유의하십시오.

Generate System Information Report

html 형식으로 보고서를 생성한 후에는 아래에 표시된 대로 웹 브라우저에서 볼 수 있습니다.

Linux System Detailed Information

8. hwinfo – 현재 하드웨어 정보 표시

hwinfo는 리눅스 시스템에 있는 하드웨어 정보를 추출하는 데 사용됩니다. CPU 정보를 표시하려면 --cpu 옵션을 사용하십시오.

$ hwinfo --cpu
Print Present Hardware Information
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

또한, 다음을 확인하십시오:

  1. Cpustat – 리눅스 시스템에서 실행 중인 프로세스에 의한 CPU 활용 모니터링
  2. CoreFreq – 리눅스 시스템용 강력한 CPU 모니터링 도구
  3. 리눅스에서 최상위 메모리 및 CPU 사용량에 따른 최상위 실행 중인 프로세스 찾기
  4. ‘Stress-ng’ 도구를 사용하여 리눅스에서 고 CPU 부하 및 스트레스 테스트 적용하는 방법

지금은 여기까지입니다! 리눅스에서 CPU 정보를 추출하는 추가 방법을 아래 피드백 양식을 통해 공유할 수 있습니다.

Source:
https://www.tecmint.com/check-linux-cpu-information/