Skip to content

How to measure CPU temperature in Linux server using lm-sensors

Posted on:November 13, 2022

In Linux, you can easily measure the temperature of your CPU using the lm-sensors package. In this tutorial, we’ll walk through the steps to install the package and measure the temperature of your server CPU.

To install lm-sensors, open a terminal window and run the following command:

sudo apt-get install lm-sensors

After installing, you need to run a detection script to identify the sensors on your system. To do this, run the following command:

sudo sensors-detect

During the detection process, you’ll be prompted with a series of questions. To accept the default settings, just press Enter for each question.

Once the detection process is complete, you can display the temperature of your CPU by running the following command:

sensors

This will display the temperature readings for all sensors detected on your system, including the temperature of your CPU.

Here is an example of the output from one of my servers:

coretemp-isa-0000
Adapter: ISA adapter
Package id 0:  +40.0 C  (high = +80.0 C, crit = +100.0 C)
Core 0:        +37.0 C  (high = +80.0 C, crit = +100.0 C)
Core 1:        +40.0 C  (high = +80.0 C, crit = +100.0 C)
Core 2:        +38.0 C  (high = +80.0 C, crit = +100.0 C)
Core 3:        +39.0 C  (high = +80.0 C, crit = +100.0 C)
Core 4:        +39.0 C  (high = +80.0 C, crit = +100.0 C)
Core 5:        +38.0 C  (high = +80.0 C, crit = +100.0 C)
Core 6:        +39.0 C  (high = +80.0 C, crit = +100.0 C)
Core 7:        +39.0 C  (high = +80.0 C, crit = +100.0 C)
Core 8:        +39.0 C  (high = +80.0 C, crit = +100.0 C)
Core 9:        +39.0 C  (high = +80.0 C, crit = +100.0 C)

nvme-pci-0900
Adapter: PCI adapter
Composite:    +36.9 C  (low  =  -0.1 C, high = +71.8 C)
                       (crit = +89.8 C)

pch_cometlake-virtual-0
Adapter: Virtual device
temp1:        +52.0 C

nvme-pci-0400
Adapter: PCI adapter
Composite:    +34.9 C  (low  =  -0.1 C, high = +71.8 C)
                       (crit = +89.8 C)

I have two SSDs named nvme-pci-0900 and nvme-pci-0400, as well as a 10-core CPU with temperature readings for each core under coretemp-isa-0000. Additionally, there is temperature data for the PCH (Platform Controller Hub), which is essentially the onboard chipset.

If you want machine-readable output, you can use the sensors -j command, which will return all data in JSON format.