How to check the CPU temperature from the Linux terminal

There are several ways to get the CPU temperature from the Linux terminal and we will explore some of the standard methods.

Standard methods

  1. sensors: The sensors command displays the temperature of various hardware components on a Linux system. It requires the lm-sensors package to be installed. Once installed, we can run the command sensors to get the temperature of the CPU, among other hardware components, as shown in the output below:

(base) ┌─[intelligence@parrot]─[~]
└──╼ $sensors
iwlwifi_1-virtual-0
Adapter: Virtual device
temp1:        +49.0°C  

acpitz-acpi-0
Adapter: ACPI interface
temp1:        +45.0°C  (crit = +128.0°C)
temp2:         +0.0°C  (crit = +128.0°C)
temp3:        +42.0°C  (crit = +128.0°C)
temp4:        +37.0°C  (crit = +128.0°C)
temp5:        +31.0°C  (crit = +128.0°C)
temp6:         +0.0°C  (crit = +128.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Package id 0:  +45.0°C  (high = +100.0°C, crit = +100.0°C)
Core 0:        +44.0°C  (high = +100.0°C, crit = +100.0°C)
Core 1:        +44.0°C  (high = +100.0°C, crit = +100.0°C)
Core 2:        +44.0°C  (high = +100.0°C, crit = +100.0°C)
Core 3:        +45.0°C  (high = +100.0°C, crit = +100.0°C)

pch_skylake-virtual-0
Adapter: Virtual device
temp1:        +42.0°C  

BAT0-acpi-0
Adapter: ACPI interface
in0:          12.95 V  
curr1:         0.00 A  

  1. cat: The cat command can read the temperature from the file /sys/class/thermal/thermal_zone0/temp. This file contains the temperature in millidegrees Celsius. To display the temperature in degrees Celsius, we can use the following command:

cat /sys/class/thermal/thermal_zone0/temp | awk '{print $1/1000}'

When we run the above command, we get the following output:

(base) ┌─[intelligence@parrot]─[~]
└──╼ $cat /sys/class/thermal/thermal_zone0/temp | awk '{print $1/1000}'
48
  1. acpi: The acpi command displays the battery status and other power-related information. It can also be used on some systems to show the CPU temperature. We can use the following control to display the CPU temperature:

acpi -t

When we run the above command, we get the following output:

(base) ┌─[intelligence@parrot]─[~]
└──╼ $acpi -t
Thermal 0: ok, 31.0 degrees C
Thermal 1: ok, 0.0 degrees C
Thermal 2: ok, 37.0 degrees C
Thermal 3: ok, 0.0 degrees C
Thermal 4: ok, 44.0 degrees C
Thermal 5: ok, 41.0 degrees C
  1. lm-sensors: The lm-sensors command is a command-line interface for reading temperature and other sensor data on Linux. We can use the following command to display the temperature of the CPU:

sensors | grep 'Core 0'

When we run the above command, we get the following output:

(base) ┌─[intelligence@parrot]─[~]
└──╼ $sensors | grep 'Core 0'
Core 0:        +48.0°C  (high = +100.0°C, crit = +100.0°C)

These are a few standard methods for getting the CPU temperature from the Linux terminal. Still, the availability and accuracy of these methods may vary depending on your specific Linux distribution and hardware configuration.