리눅스 CPU/RAM/디스크 및 OS 정보 확인하기
ℹ️이 콘텐츠에는 광고가 포함되어,판매 발생 시 수익이 발생합니다.(네이버 쇼핑 커넥트, 아마존 어필리에이트, 애드센스 등)리눅스에서 사용 중인 서버의 정보 확인이 필요한 경우가 있습니다. 간단하게 리눅스 CPU/RAM/디스크 정보를 확인할 수 있는 방법을 명령어를 이용해서 알아 보겠습니다.
✅ 리눅스 CPU 정보 확인 명령어
1. cat /proc/cpuinfo
cat /proc/cpuinfo
2. CPU 전체 개수와 물리 CPU 갯수 확인하기
# CPU 코어 전체 개수 : 전체(가상) CPU 코어는 4개임을 확인 
~]# grep -c processor /proc/cpuinfo
4
# 물리 CPU 코어 개수
~]# grep -c ^processor /proc/cpuinfo
1
# CPU 당 코어 개수
grep -c ^processor /proc/cpuinfo | wc -l
43. 하이퍼 스레딩(Hyper Threading) 적용 확인
CPU 코어 개수 대비 siblings 값이 2배로 표시될 경우 Hyper Threading 기술이 적용 된 것입니다.
~]# cat /proc/cpuinfo | egrep 'siblings|cpu cores' | head -2
siblings	: 4
cpu cores	: 4
## 
~]# cat /proc/cpuinfo | egrep 'siblings|cpu cores' | head -2
siblings	: 2
cpu cores	: 1
4. lscpu 명령어
lscpu 명령어를 이용해서 간편하게 CPU 정보를 확인할 수 있습니다.
~]# lscpu
Architecture:            x86_64
  CPU op-mode(s):        32-bit, 64-bit
  Address sizes:         40 bits physical, 48 bits virtual
  Byte Order:            Little Endian
CPU(s):                  2
  On-line CPU(s) list:   0,1
Vendor ID:               AuthenticAMD
  BIOS Vendor ID:        QEMU
  Model name:            AMD EPYC 7551 32-Core Processor
    BIOS Model name:     pc-i440fx-4.2
    CPU family:          23
    Model:               1
    Thread(s) per core:  2
    Core(s) per socket:  1
    Socket(s):           1
    Stepping:            2
    BogoMIPS:            3992.49
    Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm rep_good nopl cpuid extd_apicid
                          tsc_known_freq pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy svm cr8_legacy abm sse4
                         a misalignsse 3dnowprefetch osvw topoext perfctr_core ssbd ibpb vmmcall fsgsbase tsc_adjust bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 xsaves 
                         clzero xsaveerptr virt_ssbd arat npt nrip_save arch_capabilities
Virtualization features: 
  Virtualization:        AMD-V
  Hypervisor vendor:     KVM
  Virtualization type:   full
Caches (sum of all):     
  L1d:                   64 KiB (1 instance)
  L1i:                   64 KiB (1 instance)
  L2:                    512 KiB (1 instance)
  L3:                    16 MiB (1 instance)
NUMA:                    
  NUMA node(s):          1
  NUMA node0 CPU(s):     0,1
Vulnerabilities:         
  Itlb multihit:         Not affected
  L1tf:                  Not affected
  Mds:                   Not affected
  Meltdown:              Not affected
  Mmio stale data:       Not affected
  Retbleed:              Mitigation; untrained return thunk; SMT vulnerable
  Spec store bypass:     Mitigation; Speculative Store Bypass disabled via prctl
  Spectre v1:            Mitigation; usercopy/swapgs barriers and __user pointer sanitization
  Spectre v2:            Mitigation; Retpolines, IBPB conditional, STIBP disabled, RSB filling, PBRSB-eIBRS Not affected
  Srbds:                 Not affected
  Tsx async abort:       Not affected✅ 리눅스 RAM 용량 확인
1. cat /proc/meminfo
cat /proc/meminfo에서 리눅스 RAM 용량(현재의 메모리 사용 정보)을 확인할 수 있습니다.
cat /proc/meminfo
2. free 명령어 사용
리눅스 RAM 용량은 free 명령어를 사용해서 좀 더 보기 쉽게 확인할 수 있습니다. (-h) 옵션으로 더 보기 쉽게 확인할 수 있습니다.
~]# free -h
               total        used        free      shared  buff/cache   available
Mem:           764Mi       208Mi       370Mi        17Mi       217Mi       555Mi
Swap:          8.0Gi       159Mi       7.8Gi
~]# free -h
  total        used        free      shared  buff/cache   available
Mem:          5.8Gi       3.1Gi       754Mi        35Mi       1.9Gi       2.4Gi
Swap:         5.9Gi       808Mi       5.1Gi✅ 디스크 사용량 확인: df -h
df -h 명령으로 총 디스크 사용량을 확인할 수 있습니다.
~]# df -h
Filesystem              Size  Used Avail Use% Mounted on
devtmpfs                4.0M     0  4.0M   0% /dev
tmpfs                   383M     0  383M   0% /dev/shm
tmpfs                   153M   20M  134M  13% /run
/dev/mapper/rocky-root  119G   11G  109G  10% /
/dev/sda2               994M  275M  720M  28% /boot
/dev/sda1                99M  7.0M   92M   8% /boot/efi
tmpfs                    77M     0   77M   0% /run/user/1000
~]# ✅ 각각의 서버 정보 확인
## 서버 모델명 확인
dmidecode -s system-product-name
## 서버 모델명 확이. 좀더 자세히 
dmidecode | grep "Product Name:"
# OS 종류와 버전 정보(간단히)
~]# cat /etc/redhat-release
Rocky Linux release 9.3 (Blue Onyx)
# OS 종류와 버전 정보(/etc/*release*)
~]# cat /etc/*release*
NAME="Rocky Linux"
VERSION="9.3 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.3"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.3 (Blue Onyx)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
SUPPORT_END="2032-05-31"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"
ROCKY_SUPPORT_PRODUCT_VERSION="9.3"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.3"
Rocky Linux release 9.3 (Blue Onyx)
Rocky Linux release 9.3 (Blue Onyx)
Derived from Red Hat Enterprise Linux 9.3
Rocky Linux release 9.3 (Blue Onyx)
cpe:/o:rocky:rocky:9::baseos
# OS 종류와 버전 정보(rpm 명령) 
~]# rpm -qa | grep release
rocky-release-cloud-9-1.el9.noarch
epel-release-9-7.el9.noarch
rocky-release-9.3-1.2.el9.noarch
remi-release-9.3-2.el9.remi.noarch
## OS 버전 확인(/proc/version )
~]# cat /proc/version 
Linux version 5.14.0-162.12.1.el9_1.0.2.x86_64 (mockbuild@dal1-prod-builder001.bld.equ.rockylinux.org) (gcc (GCC) 11.3.1 20220421 (Red Hat 11.3.1-2), GNU ld version 2.35.2-24.el9) #1 SMP PREEMPT_DYNAMIC Mon Jan 30 22:14:42 UTC 2023
## CPU 모델명 확인 
cat /proc/cpuinfo | grep name