3 Ways to Check CPU and GPU temperatures on Linux

You need to check CPU and GPU temperatures to better optimizing your device’s performance. It is even more crucial for gamers and animators to try to keep the temperature low to decrease render times or increase game performance.

Tools to check CPU and GPU temperatures

Linux doesn’t come with a very intuitive way of checking in on your CPU/GPU. So in this article, we look at 3 different ways you can monitor your hardware temperature levels.

1. lm-sensors

There are tons of third-party command-line utilities like as acpi , i7z and tmon to display the hardware temperatures but none are as elaborate and universal as lm-sensors which is a free and open-source application that not only provides CPU temperatures but voltage, and fan information too.

Ubuntu/Mint/Debian

sudo apt install lm-sensors

Arch/Manjaro Linux

sudo pacman -S lm_sensors

Fedora

sudo dnf install lm_sensors

lm-sensors or lm_sensors can be found in the official repositories of almost all distributions.

How to use

To check temperatures, first execute

sensors-detect 

which will detect all the relevant sensors on the device. Say ‘y’ or ‘yes’ to all prompts. lm-sensors also advises you to run the following command to reload the modules.

/etc/init.d/kmod start

Now execute the following the run the program.

sensors

and you will get a output something like this, listing all the necessary hardware info you need.

check CPU and GPU temperatures on Linux

2. psensor

If you don’t want to open up your terminal again and again and want a graphical option to check your temperature, you can get psensors which not only displays you real time sensors data but makes easy to read graphs so you can monitor and analyze hardware performance.

psensor depends on lm-sensors for and hddtemp to check CPU and GPU temperatures and drive temperatures respectively. So make sure to install hddtemp and lm-sensors before installing psensor

Ubuntu/Mint/Debian

sudo apt install lm-sensors hddtemp
sudo sensors-detect
sudo apt install psensor
psensor

Arch/Manjaro Linux

sudo pacman -S lm_sensor hddtemp
sudo sensors-detect
sudo pacman -S psensor
psensor

RHEL/Fedora

sudo yum install lm_sensors hddtemp make gcc gtk3-devel gtop2 lm_sensors-devel libatasmart-devel libcurl-devel  libmicrohttpd-devel help2man libnotify-devel libgtop2-devel 
curl wpitchoune.net/psensor/files/psensor-1.2.1.tar.gz
tar -xvf psensor-1.2.1
cd psensor-1.2.1
./configure;make clean all
sudo make install
sensors-detect 
psensor 

After installing psensor, execute psensor to run it.

Psensor to check CPU and GPU temperatures on Linux

You can see the list of sensors (usually to the right by default) and select the ones that you want on a graph. Here I have plotted the temperature of the first core of my processor against the CPU usage.

Without using third-party apps

There is a way to get temperatures without using third-party applications like lm-sensors. In fact, this is the way, third-party applications like lm-sensors get their data and present it in a more accessible way.

To understand how this works, we need to understand that everything on Linux is a file. What this means is that we can access any modules, devices, is stored on the system as a file.

For example, if you want to know the brightness level of your caps-lock key, it’s stored in /sys/class/leds/input15\:\:capslock/brightness and you can read that file to know the brightness levels.

Similarly, all sensor data is stored in /sys/class/thermal/ various directories named thermal_zoneX . To get all the temperatures, run

cat /sys/class/thermal/thermal_zone*/temp

This will give you a list of temperatures in Celsius. To know what these temperatures represent, you can read a file named in each directory. For example to know what the first temperature represents, run

cat /sys/class/thermal/thermal_zone1/type

The CPU temperature is the thermal zone with type x86_pkg_temp.

You can also do some Linux string manipulation magic, and use the following command to list all types with their corresponding temperature.

paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) | column -s $'\t' -t | sed 's/\(.\)..$/.\1°C/'
No Third Party Temp

Conclusion

We have now seen multiple ways of checking your hardware temperatures and other info which you can use to optimize device performance. If you want to learn more about CPU optimization for Linux, you can visit Cpu Frequency Scaling. Have fun!