Debian系统中的cpuinfo工具无法直接显示CPU温度。cpuinfo(通常位于/proc/cpuinfo)主要提供CPU型号、核心数、频率等硬件基础信息,不包含温度数据。
lm-sensors工具(推荐)lm-sensors是Linux下最常用的硬件传感器监测工具,支持绝大多数CPU、主板传感器的温度读取。
lm-sensors:sudo apt update && sudo apt install lm-sensors
安装完成后,执行sensors-detect检测系统中的传感器模块(按提示选择默认选项即可):sudo sensors-detect
sensors命令,将显示所有检测到的传感器信息(包括CPU温度):sensors
输出示例:Core 0: +45.0°C (high = +80.0°C, crit = +100.0°C)
Core 1: +43.0°C (high = +80.0°C, crit = +100.0°C)
/sys文件系统中的温度数据Linux内核通过/sys虚拟文件系统暴露硬件传感器数据,CPU温度通常位于thermal_zone目录下。
cat /sys/devices/virtual/thermal/thermal_zone*/temp
示例输出(假设thermal_zone0对应CPU):45000 # 表示45.0°C
若需自动计算摄氏度,可使用awk:cat /sys/devices/virtual/thermal/thermal_zone*/temp | awk '{print $1/1000 "°C"}'
htop工具(交互式查看)htop是增强版进程查看器,部分系统配置后可显示CPU温度。
htop:sudo apt install htop
启动htop后,按下F5进入树状视图,若系统支持,会在CPU使用率下方显示温度信息(如“Temp: 45.0°C”)。coretemp模块若使用Intel CPU,可通过coretemp内核模块直接读取核心温度。
coretemp模块:sudo modprobe coretemp
查看温度(路径可能因CPU型号不同而变化):cat /sys/devices/virtual/thermal/thermal_zone*/temp
msr-tools工具若使用AMD CPU,可通过msr-tools读取MSR寄存器中的温度数据(需root权限)。
msr-tools:sudo apt install msr-tools
读取温度(需参考AMD官方文档解析输出):sudo rdmsr -p0 0x1FC
sensors、rdmsr)需要root权限,建议使用sudo运行。/sys下的温度文件通常以毫摄氏度为单位,需转换后阅读;sensors命令会直接显示摄氏度。