CentOS查看版本及CPU信息的常用方法
一、查看CentOS系統(tǒng)版本
1. 使用hostnamectl命令
執(zhí)行以下命令可直接顯示系統(tǒng)版本及內(nèi)核信息:
hostnamectl
輸出示例:
Static hostname: localhost.localdomain Operating System: CentOS Linux 7 (Core) Kernel: Linux 3.10.0-1160.el7.x86_64
2. 查看/etc/centos-release文件
通過讀取系統(tǒng)文件獲取版本信息:
cat /etc/centos-release
輸出示例:
CentOS Linux release 7.9.2009 (Core)
二、查詢CPU詳細(xì)信息
1. 使用lscpu命令
快速獲取CPU架構(gòu)、核心數(shù)及線程數(shù):
lscpu
輸出示例:
Architecture: x86_64 CPU(s): 4 Thread(s) per core: 2 Model name: Intel(R) Xeon(R) CPU E5-2678 v3 @ 2.50GHz
2. 分析/proc/cpuinfo文件
查看完整的CPU配置信息:
cat /proc/cpuinfo | grep "model name" | uniq
輸出示例:
model name : Intel(R) Xeon(R) Gold 6148 CPU @ 2.40GHz
三、組合命令應(yīng)用
同時顯示系統(tǒng)版本和CPU型號:
echo "系統(tǒng)版本: $(cat /etc/centos-release) | CPU型號: $(lscpu | grep 'Model name' | awk -F: '{print $2}')"