1

What is the best way to get the CPU temperature on Linux from the command line?

On one small portable system, I was able to get the CPU temperature from here:

/sys/class/thermal/thermal_zone0/temp

or here:

/sys/class/thermal/thermal_zone1/temp

However some people say to look for the "coretemp" value, which doesn't seem to exist on my system.

Is there an official best practice for getting CPU temperature?

1
  • May be dependent on Distro, but e.g. Linux Mint has a sensors command. Also a whole world (well, 10KB) of sensors.conf. Commented Jan 8 at 22:34

1 Answer 1

0

You can get the values from /sys/class/thermal/thermal_zone*/temp and know what they correspond by reading the matching thermal_zone* /sys/class/thermal/thermal_zone*/type

So this (taken from here) will list the available types and readings:

$ paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp)
2
  • What are the thermal zones 0 and 1 in reference to?
    – ppppppp2
    Commented Jan 11 at 12:59
  • As far as I know, it depends on the hardware and the modules. I just checked a raspberry 2 and it only has one thermal zone, identified as cpu-thermal, while two other desktops return two and three readings each, with other names. Probably sensors is a safer/easier bet. Given the array of hardware Linux runs on, I don't think there is a general way to do it without some additional hardware related mapping. Loading a module like coretemp may expose more information that you could pick up by reading other files inside the thermal_zone folder or get directly from sensors. Commented Jan 11 at 17:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .