Checking your CPU temperature in Linux

A server or computer can get hot, depending on the environment that it’s in. It is always important to make sure components aren’t overheating, especially the CPU. There is a way to do this by checking your CPU temperature in Linux with several tools.

Lm-sensors

The lm-sensors package includes a couple of utilities for detecting your CPU temperature directly from the motherboard controller. This helps with diagnosing potential problems with your machine. In order to install this package run the following:

Debian/Ubuntu:

sudo apt-get install lm-sensors

CentOS/Fedora/RHEL:

sudo yum -y install lm_sensors

Note: In CentOS, there is an underscore for lm_sensors.

We have now installed lm-sensors package. From here, it is as simple as a single command to execute:

sudo sensors

The CPU name will be displayed and temperatures for each core. To see if there are any monitoring modules on the current motherboard, then run the following command to detect them:

sudo sensors-detect
CPU temperature sensors detect

There will be several prompts asking whether to scan sections of the motherboard. Several lines of results will be printed with a yes or no. At the end, you will be asked whether you want to add these to your modules. Go ahead and type in yes.

Lets go ahead and monitor it in real-time.

Monitor CPU temperature live

Monitoring the CPU temperature can also be done live with this command:

watch sensors

Now we can watch the CPU temperature in Linux for all cores in real time. Now you can rest easy knowing that your CPU may not be on fire or that you know when to extinguish the flames!