Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

Linux 獲取 CPU 詳細信息:/proc/cpuinfo 完整解析

編輯:Linux 系統常見問題解答

在 Linux 下,/proc/cpuinfo 是獲取處理器硬件信息的權威來源。本文整理了常用的提取命令,幫助你快速掌握物理 CPU 數量、核心數、線程數及型號等關鍵指標。

核心查詢命令

  1. 物理 CPU 個數
    cat /proc/cpuinfo | grep 'physical id' | sort | uniq | wc -l
  2. 每顆物理 CPU 的物理核心數
    cat /proc/cpuinfo | grep 'core id' | sort | uniq -c | wc -l
    或直接查看:cat /proc/cpuinfo | grep 'cpu cores' | uniq | awk -F: '{print $2}'
  3. 每顆物理 CPU 的邏輯核心數(含超線程)
    cat /proc/cpuinfo | grep 'siblings' | uniq | awk -F: '{print $2}'
  4. 邏輯核心總數
    cat /proc/cpuinfo | grep 'processor' | sort | uniq -c | wc -l
    等同於 物理 CPU 數 × 每顆 CPU 邏輯核心數。
  5. CPU 型號
    cat /proc/cpuinfo | grep 'model name' | cut -f2 -d: | uniq -c

實戰解讀示例

# cat /proc/cpuinfo | grep physical | uniq -c
4 physical id : 0
4 physical id : 1

輸出說明:系統有 2 顆物理 CPU(physical id 0 和 1),每顆 CPU 顯示 4 個邏輯核心(對應 4 行),推測每顆 CPU 為 2 物理核心 + 超線程。

掌握這些命令,可在不安裝額外工具的情況下完整掌握服務器 CPU 拓撲結構。

Copyright © Windows教程網 All Rights Reserved