IT News/Ubuntu

리눅스에서 CPU 정보를 확인하는 8가지 명령어 (cpuinfo, lscpu, hardinfo, lshw, nproc, dmidecode, cpuid, inxi)

skyLove1982 2017. 1. 10. 14:45
반응형

CPU 정보에는 프로세서에 대한 정보를 가지고 있는데 즉 CPU의 구조, 판매자, 모델, 코어갯수,  코어의 속도 등의 정보를 포함하고 있습니다. 여기에는 리눅스에서 이와같은 세부사항을 얻을 수 있는 몇가지 명령어를 정리해 보았습니다.



1. /proc/cpuinfo


/proc/cpuinfo 파일은 CPU 코어 개별적인 세부사항들을 가지고 있습니다. 아래를 보시면 제조사가 GenuineIntel 로 되어있고 모델명은 Q8400 이며 코어가 4개이며 클럭 속도는 2.66GHz 인것을 알 수가 있습니다.  ( less /proc/cpuinfo 를 입력하시면 아래와 같은 화면을 보실 수가 있습니다. 참고로 종료를 하실때에는 q 를 입력하시면 됩니다.)


less /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 23
model name      : Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz
stepping        : 10
microcode       : 0xa07
cpu MHz         : 1998.000
cache size      : 2048 KB
physical id     : 0
siblings        : 4
core id         : 0
cpu cores       : 4
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 lm constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dtherm tpr_shadow vnmi flexpriority
bogomips        : 5303.14
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management


모든 프로세서 또는 코어가 속도와 캐쉬 사이즈와 모델명이 설명과 함께 각각 리스트 되어 표시가 됩니다.


프로세싱 유닛 숫자를 구하기 위해서 grep 과 wc 을 아래와 같이 사용합니다. 그러면 아래와 같이 4가 표시가 됩니다. 참고로 결과값은 CPU 마다 다릅니다.


$ cat /proc/cpuinfo | grep processor | wc -l
4


/proc/cpuinfo 를 통해서 보여지는 프로세서의 숫자는 프로세서의 실제 코어 갯수가 아닐수도 있습니다. 예를들어 2개의 코어를 가진 프로세서로 하이퍼쓰레딩(hyperthreading)을 한다면  4개의 코어로 표시가 될 수 있습니다.



코어의 실제 갯수를 구하기 위해서는 코어 아이디를 체크해야 합니다.


$ cat /proc/cpuinfo | grep 'core id'
core id         : 0
core id         : 2
core id         : 1
core id         : 3


위에서 보듯이 4개의 다른 코어 아이디를 확인할 수 있으며 이를 통해 실제 코어의 갯수가 4개임을 알 수 있습니다.





2. lscpu


lscpu 는 어떠한 옵션을 필요로 하지 않고 간편하고 빠르게 보여줄 수 있는 명령어 입니다. 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:    1
Core(s) per socket:    4
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 23
Stepping:              10
CPU MHz:               1998.000
BogoMIPS:              5303.14
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              2048K
NUMA node0 CPU(s):     0-3





3. hardinfo


hardinfo 명령어는 다양한 하드웨어 구성정보(hardware components)를 리포트로 생성하여 보여주는 gtk 기반의  그래픽 사용자 인터페이스 툴(gui tool) 입니다. 하지만 또한 gui 디스플레이가 가능하지 않을때 코멘드 라인(command line)으로 실행할 수 있습니다.


$ hardinfo | less


만일 여러개의 하드웨어 요소들이 있다면 많은 양의 리포트가 생성 (/pro 디렉토리의 파일을 읽음)될 수 있습니다. CPU 정보는 리포트가 생성될때에 첫 부분에 위치하게 되며 또한 리포트는 테스트 파일로 쓰여질 수 있습니다.


hardinfo 는 리포트가 표시되기전에 몇가지의 벤치마크 테스트를 하기때문에 몇분이 소요될 수도 있습니다.





4. lshw


lshw 명령어는 CPU 에 대한 정보를 제한적으로 보여줄 수 있습니다. lshw 로 다양한 하드웨어 구성요서에 대한 기본적인 정보를 보여주며, '-class' 옵션을 사용하여 특정 하드웨어 요소에 대한 정보를 뽑아 올 수 있습니다.


$ hardinfo | less$ sudo lshw -class processor
  *-cpu                  
       description: CPU
       product: Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz
       vendor: Intel Corp.
       physical id: 0
       bus info: cpu@0
       version: Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz
       slot: LGA 775
       size: 1998MHz
       capacity: 4GHz
       width: 64 bits
       clock: 333MHz
       capabilities: 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 x86-64 constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dtherm tpr_shadow vnmi flexpriority cpufreq


판매자, 모델과 프로세서의 속도는 맞게 보여집니다. 그러나 위의 출력된 결과로부터 프로세서의 갯수를 추측하여 구하는 것은 불가능합니다.





5. nproc


nproc 명령어는 사용가능한 프로세싱 유닛의 갯수만을 출력합니다. 여기의 주의해야 할점은 프로세싱 유닛의 숫자가 항상 실제 코어의 갯수와 일치하지는 않는다는 점입니다.


$ nproc
4





6. dmidecode


dmidecode 명령어는 CPU에 대한 정보를 보여주는데, 여기에는 소켓타입(socket type), 판매자(vendor name), 다양한 플래그(various flags) 값들을 포함합니다.


$ sudo dmidecode -t 4
# dmidecode 2.12
SMBIOS 2.4 present.

Handle 0x0000, DMI type 4, 35 bytes
Processor Information
        Socket Designation: LGA 775
        Type: Central Processor
        Family: Pentium D
        Manufacturer: Intel(R) Corporation
        ID: 7A 06 01 00 FF FB EB BF
        Signature: Type 0, Family 6, Model 23, Stepping 10
        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)
                CMOV (Conditional move instruction supported)
                PAT (Page attribute table)
                PSE-36 (36-bit page size extension)
                CLFSH (CLFLUSH instruction supported)
                DS (Debug store)
                ACPI (ACPI supported)
                MMX (MMX technology supported)
                FXSR (FXSAVE and FXSTOR instructions supported)
                SSE (Streaming SIMD extensions)
                SSE2 (Streaming SIMD extensions 2)
                SS (Self-snoop)
                HTT (Multi-threading)
                TM (Thermal monitor supported)
                PBE (Pending break enabled)
        Version: Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz
        Voltage: 1.6 V
        External Clock: 333 MHz
        Max Speed: 4000 MHz
        Current Speed: 2666 MHz
        Status: Populated, Enabled
        Upgrade: Socket LGA775
        L1 Cache Handle: 0x0003
        L2 Cache Handle: 0x0001
        L3 Cache Handle: Not Provided
        Serial Number: Not Specified
        Asset Tag: Not Specified
        Part Number: Not Specified





7. cpuid


cpuid 명령어는 인텔과 AMD 프로세서에 대한(Intel and AMD x86 processors) CPUID 정보를 가져옵니다(fetch).


이 프로그램은 우분트(ubuntu)에서 apt 명령어를 사용하여 설치할 수 있습니다.


$ sudo apt-get install cpuid


아래는 출력 예제 입니다.


$ cpuid

.....

Vendor ID: "GenuineIntel"; CPUID level 13

Intel-specific functions:
Version 0001067a:
Type 0 - Original OEM
Family 6 - Pentium Pro
Model 7 - Pentium III/Pentium III Xeon - external L2 cache
Stepping 10
Reserved 4

Extended brand string: "Intel(R) Core(TM)2 Quad CPU    Q8400  @ 2.66GHz"
CLFLUSH instruction cache line size: 8
Initial APIC ID: 2
Hyper threading siblings: 4

Feature flags bfebfbff:
FPU    Floating Point Unit
VME    Virtual 8086 Mode Enhancements
DE     Debugging Extensions
PSE    Page Size Extensions
TSC    Time Stamp Counter
MSR    Model Specific Registers
PAE    Physical Address Extension
MCE    Machine Check Exception
CX8    COMPXCHG8B Instruction
APIC   On-chip Advanced Programmable Interrupt Controller present and enabled
SEP    Fast System Call
MTRR   Memory Type Range Registers
PGE    PTE Global Flag
MCA    Machine Check Architecture
CMOV   Conditional Move and Compare Instructions
FGPAT  Page Attribute Table
PSE-36 36-bit Page Size Extension
CLFSH  CFLUSH instruction
DS     Debug store
ACPI   Thermal Monitor and Clock Ctrl
MMX    MMX instruction set
FXSR   Fast FP/MMX Streaming SIMD Extensions save/restore
SSE    Streaming SIMD Extensions instruction set
SSE2   SSE2 extensions
SS     Self Snoop
HT     Hyper Threading
TM     Thermal monitor
31     reserved

.....





8. inxi


inxi 는 시스템의 다양한 하드웨어 구성요소(components)에 대한 정보를 다른 프로그램을 사용하여 읽기 쉽게 잘 구조화된 리포트로 생성하기 위한 스크립트입니다. 자세한 것은 여기를 참고하세요.


inxi 를 설치하시려면 아래와 같이 설치하실 수가 있습니다.


$ sudo apt-get install inxi


CPU 와 프로세서 관련된 정보를 표시해 보면 아래와 같습니다.


$ inxi -C
CPU:     Quad core Intel Core2 Quad CPU Q8400 (-MCP-) cache: 2048 KB flags: (lm nx sse sse2 sse3 sse4_1 ssse3 vmx)
           Clock Speeds: 1: 1998.00 MHz 2: 1998.00 MHz 3: 1998.00 MHz 4: 1998.00 MHz



참고 URL : http://www.binarytides.com/linux-cpu-information/

반응형