Computer >> 컴퓨터 >  >> 프로그래밍 >> Bash 프로그래밍

리눅스 완전 정복: 상세한 CPU 정보를 확인하는 9가지 필수 명령어

이전 글에서는 리눅스에서 시스템 및 하드웨어 정보를 수집하는 데 유용한 10가지 명령어를 정리해 소개했습니다. 이번 가이드에서는 범위를 좁혀 CPU(프로세서)에 집중하고, 여러분의 머신에 탑재된 CPU에 대한 상세한 정보를 추출하는 다양한 방법을 알아보겠습니다.

간단히 개요를 살펴보면, CPU 아키텍처, vendor_id, 모델, 모델명, CPU 코어 수, 각 코어의 속도 등 다양한 정보를 조회하는 방법을 다룹니다.
핵심은 사실 /proc/cpuinfo 파일 하나에 모든 정보가 담겨 있다는 점입니다. 이후에 소개할 다른 명령어나 유틸리티들도 결국 이 파일을 기반으로 출력 결과를 만들어냅니다.

그럼 지금부터 리눅스에서 CPU 정보를 확인할 수 있는 9가지 명령어를 하나씩 살펴보겠습니다.

1. cat 명령어로 CPU 정보 확인하기

가장 간단한 방법은 cat 명령어로 /proc/cpuinfo 파일의 내용을 직접 확인하는 것입니다.

$ cat /proc/cpuinfo

리눅스 CPU 정보 예시는 다음과 같습니다.

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 명령어를 활용하면 좋습니다. grep은 정규 표현식과 일치하는 라인을 찾아주는 CLI 도구로, 이를 조합하면 제조사 이름, 모델명, 프로세서 수, 코어 수 등 원하는 항목만 깔끔하게 출력할 수 있습니다.

$ cat /proc/cpuinfo | grep 'vendor' | uniq #제조사 이름 확인
$ cat /proc/cpuinfo | grep 'model name' | uniq #모델명 출력
$ cat /proc/cpuinfo | grep processor | wc -l #프로세싱 유닛 개수 세기
$ cat /proc/cpuinfo | grep 'core id' #개별 코어 확인

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 명령어(instruction)에서 수집한 CPU 전체 정보를 덤프하며, 그 정보를 바탕으로 x86 CPU의 정확한 모델까지 식별해 줍니다.

먼저 사용 전에 패키지를 설치해야 합니다.

$ sudo apt install cpuid #Debian/Ubuntu 계열
$ sudo yum install cpuid #RHEL/CentOS 계열
$ sudo dnf install cpuid #Fedora 22+

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

$ cpuid

x86 CPU 정보 출력 예시입니다.

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는 어떤 리눅스 시스템이든 하드웨어 정보를 조회할 수 있는 도구입니다. 컴퓨터의 DMI(SMBIOS라고도 함) 테이블 내용을 사람이 읽기 쉬운 형태로 덤프해 주어 손쉽게 정보를 확인할 수 있습니다. SMBIOS 규격은 다양한 DMI 유형을 정의하고 있는데, CPU 정보를 보려면 "processor" 유형을 지정하면 됩니다.

$ 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)
.....

참고로 dmidecode는 시스템의 BIOS/펌웨어가 제공하는 정보를 그대로 읽어오기 때문에 일부 가상화 환경에서는 실제 하드웨어와 다른 값이 표시될 수 있습니다.

5. Inxi 도구 – 리눅스 시스템 정보 표시

Inxi는 콘솔과 IRC(Internet Relay Chat) 양쪽에서 사용할 수 있도록 만들어진 강력한 명령줄 기반 시스템 정보 스크립트입니다. 이 도구를 사용하면 하드웨어 정보를 즉석에서 빠르게 확인할 수 있습니다.

설치 방법은 다음과 같습니다.

$ sudo apt install inxi #Debian/Ubuntu 계열
$ sudo yum install inxi #RHEL/CentOS 계열
$ sudo dnf install inxi #Fedora 22+

코어별 클럭 속도와 최대 클럭 속도(지원되는 경우)를 포함한 전체 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

코어별 현재 동작 클럭이 함께 표시되므로 CPU 부하 상태를 파악하는 데도 유용합니다.

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

현재 동작 클럭(size), 최대 용량(capacity), 물리 코어 수와 스레드 수까지 상세히 확인할 수 있습니다.

7. hardinfo – GTK+ 창으로 하드웨어 정보 확인

hardinfo는 GUI 환경에서 GTK+ 창을 통해 하드웨어 정보를 표시해 주는 도구입니다. 설치 방법은 다음과 같습니다.

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

설치 후에는 다음 명령어로 실행합니다.

$ hardinfo 
리눅스 완전 정복: 상세한 CPU 정보를 확인하는 9가지 필수 명령어리눅스 시스템 정보 화면

hardinfo의 장점은 GUI 외에도 하드웨어 정보 보고서를 생성할 수 있다는 점입니다. "Generate Report(보고서 생성)" 버튼을 클릭한 뒤, 아래 인터페이스에서 "Generate" 버튼을 누르면 됩니다. 이때 생성할 하드웨어 정보 카테고리를 선택할 수 있습니다.

리눅스 완전 정복: 상세한 CPU 정보를 확인하는 9가지 필수 명령어시스템 정보 보고서 생성 화면

HTML 형식으로 보고서가 생성되면 웹 브라우저에서 아래와 같이 열어볼 수 있습니다.

리눅스 완전 정복: 상세한 CPU 정보를 확인하는 9가지 필수 명령어리눅스 시스템 상세 정보 보고서

생성된 보고서는 문서로 보관하거나 동료에게 공유하기에도 좋습니다.

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

hwinfo는 리눅스 시스템에 존재하는 하드웨어 정보를 추출하는 데 사용됩니다. 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

함께 읽으면 좋은 글:

  1. Cpustat – 리눅스에서 실행 중인 프로세스별 CPU 사용률 모니터링하기
  2. CoreFreq – 리눅스 시스템을 위한 강력한 CPU 모니터링 도구
  3. 리눅스에서 메모리와 CPU 사용량 기준으로 상위 프로세스 찾는 방법
  4. 'Stress-ng' 도구로 리눅스에 높은 CPU 부하를 걸어 스트레스 테스트하는 방법

여기까지 리눅스에서 CPU 정보를 확인하는 9가지 방법을 살펴봤습니다. 실무에서는 간단한 확인에는 lscpu, 상세 분석에는 /proc/cpuinfodmidecode를 조합해 사용하는 것이 효율적입니다. 그 외에 CPU 정보를 추출하는 다른 방법이 있다면 피드백 폼을 통해 공유해 주세요!