How to Get CPU Temperature on Ubuntu Linux

check cpu temperature on linux

Hardware overheating often creates a bad performance of your system. Monitoring hardware temperature can help you diagnose any CPU overheating problems of the system. The source of laptop overheating normally comes from extensive CPU, GPU (video cards), or hard disk temperature.

If your laptop is getting hot, make sure the laptop is positioned properly so it won't restrict airflow. You must have a good, clean laptop cooler, not dusty, and remove any unwanted software that uses high CPU. Also running the laptop in power saving mode reduces overheating.

In this tutorial, we will learn how to get the CPU temperature on Ubuntu Linux from command line as well as from Desktop.

1) Check CPU temperature using Lm_Sensors

Lm_sensors is a command-line tool that is used to show the current readings of all chip sensor data, including CPU temperature. By default, Lm_sensors are not installed in most Linux distributions, therefore, we have to install them ourselves.

So first let's check how to install lm-sensors package on various Linux distros.

On Ubuntu/Debian

Open the terminal on Ubuntu by pressing the shortcut key CTRL + ALT + T  from your keyboard. Then install Lm_Sensors by running the following command which I have tested on Ubuntu 18.04, Ubuntu 20.04, and Debian 10:

$ sudo apt install lm-sensors

Install Psensor Server if you want to print the temperature and fan speed of a remote server.

$ sudo apt-get install psensor-server

On Arch Linux

To install lm_sensors on Arch Linux, enable the extra repository in '/etc/pacman.conf'. Then run the following pacman command from the terminal:

$ sudo pacman -S lm_sensors

On Fedora

Use dnf command to install lm_sensors on Fedora Linux.

$ sudo dnf install lm_sensors

On CentOS/RHEL

Use yum command to install lm_sensors on CentOS 7 and RHEL 7

$ sudo yum install lm_sensors

Detecting compatible sensors on Ubuntu Linux

Next, we need to detect hardware monitoring chips installed in our laptops. So now we can start the detection of our laptop hardware sensors. This will provide information about:

  • Sensors embedded in CPUs and other super I/O chips
  • Hardware monitoring chips accessed through I/O ports and SMBus/I2C bus on our system

We do that by typing command sudo sensors-detect:

$ sudo sensors-detect 
# sensors-detect revision 6284 (2015-05-31 14:00:33 +0200)
# System: LENOVO 20FMS1W300 [ThinkPad T460] (laptop)
# Kernel: 4.15.0-96-generic x86_64
# Processor: Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz (6/78/3)

This program will help you determine which kernel modules you need
to load to use lm_sensors most effectively. It is generally safe
and recommended to accept the default answers to all questions,
unless you know what you're doing.

Some south bridges, CPUs or memory controllers contain embedded sensors.
Do you want to scan for them? This is totally safe. (YES/no): yes
Silicon Integrated Systems SIS5595...                       No
VIA VT82C686 Integrated Sensors...                          No
VIA VT8231 Integrated Sensors...                            No
AMD K8 thermal sensors...                                   No
AMD Family 10h thermal sensors...                           No
AMD Family 11h thermal sensors...                           No
AMD Family 12h and 14h thermal sensors...                   No
AMD Family 15h thermal sensors...                           No
AMD Family 16h thermal sensors...                           No
AMD Family 17h thermal sensors...                           No
AMD Family 15h power sensors...                             No
AMD Family 16h power sensors...                             No
Intel digital thermal sensor...                             Success!
    (driver `coretemp')
Intel AMB FB-DIMM thermal sensor...                         No
Intel 5500/5520/X58 thermal sensor...                       No
VIA C7 thermal sensor...                                    No
VIA Nano thermal sensor...                                  No

Some Super I/O chips contain embedded sensors. We have to write to
standard I/O ports to probe them. This is usually safe.
Do you want to scan for Super I/O sensors? (YES/no): yes

..................

Display CPU temperature in the command line

We have successfully installed lm-sensors package and we have successfully detected supported sensors on our Ubuntu Linux powered laptop.

Now we can execute the following command to see temperature data:

sensors

Note that the results will differ for your computer.

$ sensors
iwlwifi_1-virtual-0
Adapter: Virtual device
temp1:        +33.0°C  

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

BAT0-acpi-0
Adapter: ACPI interface
in0:         +12.45 V  

coretemp-isa-0000
Adapter: ISA adapter
Package id 0:  +39.0°C  (high = +100.0°C, crit = +100.0°C)
Core 0:        +39.0°C  (high = +100.0°C, crit = +100.0°C)
Core 1:        +38.0°C  (high = +100.0°C, crit = +100.0°C)

thinkpad-isa-0000
Adapter: ISA adapter
fan1:           0 RPM
temp1:        +38.0°C  
temp2:            N/A  
temp3:         +0.0°C  
temp4:         +0.0°C  
temp5:         +0.0°C  
temp6:         +0.0°C  
temp7:         +0.0°C  
temp8:         +0.0°C  

BAT1-acpi-0
Adapter: ACPI interface
in0:         +12.49 V  

acpitz-acpi-0
Adapter: ACPI interface
temp1:        +38.0°C  (crit = +128.0°C)

You can also use the watch command to run sensors command constantly, which will display sensor output changes on screen:

$ watch sensors

2) Check CPU temperature with Psensor GUI tool

We’re going to use a GUI tool, Psensor, that allows you to monitor hardware temperature on Linux.

With Psensor you can check the following:

  • The temperature of the motherboard and CPU sensors and NVidia GPUs
  • The temperature of the hard disk drives
  • The rotation speed of the fans
  • Monitor CPU usage

The latest version of Psensor also provides an applet indicator for Ubuntu and thus it makes the monitoring of hardware temperature even easier on Ubuntu. You can choose to display the temperature right in the top panel itself. It can even send a desktop notification when the temperature exceeds the limit.

We can proceed with the installation of Psensor by using the command below:

Ubuntu/Debian

$ sudo apt install psensor

Fedora

$ sudo dnf install https://raw.githubusercontent.com/rpmsphere/x86_64/master/p/psensor-1.2.0-5.1.x86_64.rpm

CentOS and RHEL

$ sudo yum install https://raw.githubusercontent.com/rpmsphere/x86_64/master/p/psensor-1.2.0-5.1.x86_64.rpm

Once installed, run the application by looking for it in the Unity Dashboard. On the first run, you may configure which stats (sensors) you want to collect with Psensor.

psensor

Psensor temperature monitor

psensor graph

Psensor cpu temperature graph

If you want to show the CPU statistics including temperature in the top panel, go to 'Sensor Preferences'. Then under the 'Application Indicator' menu, select the component for which you want to display the temperature. Then check the 'Display sensor' in the label option.

psensor preferences

3) Using 'Hardinfo' to check CPU temperature

Hardinfo is a system profiler and benchmark tool used in Linux to display hardware information in GUI. You can also check CPU temperature from the GUI - Devices - Sensors.

On Ubuntu and Debian

$ sudo apt install hardinfo

On Arch Linux you can find hardinfo in community repo

$ sudo pacman -S hardinfo

Run the following command from the terminal to display hardware information on GUI.

# hardinfo
hardinfo - cpu sensors

Hardinfo - cpu sensors

hardinfo processor

Hardinfo processor

Using 'i7z' to find CPU temperature

i7z is a command-line tool to print CPU information on Intel Core i7, i5, i3 processors, and also reports CPU temperature. i7z needs to be run as root or user with sudo privilege.

To install on ubuntu run the following command:

$ sudo apt install i7z
i7z linux

i7z command output

Conclusion

Apart from this, you can try using TLP and thermald,can help you control CPU temperature on Linux. Cpufreq is another tool that can help you save battery and reduce the laptop overheating which works very well on Ubuntu.

Few years before I used 'Conky' which is a lightweight desktop system monitor that can show stats of CPU, memory, swap space, disk storage, temperatures, processes, network interfaces, battery power, etc.

If you want to check temperatures without 3rd party tools, look in /sys/devices/virtual/thermal/thermal_zone1/temp file.

To check hard disk temperature you can install hddtemp package.

Finally, if you have any questions or feedback, feel free to leave a comment.

Slavisa Milojkovic 12:19 am

Comments

Your email address will not be published. Required fields are marked *

12 Comments

  1. Thanks for the article.

    One quick question, does i7z work well with the i9 generation of CPUs? I know it gives the temperature and frequency info but is it accurate? I found some discrepancy when giving AVX load and saw unreliable CPU frequencies in i7z.

    1. Hi Ram,

      From my understanding, it supports only i3, i5, and i7 based Core processors from Intel (including Nehalems, Sandy Bridge and Ivy Bridge)

  2. Those are all great methods for other distros. On Ubuntu I always use inxi though, like:
    inxi -sBxxx

    1. Hi Crito,

      I just tried installing inxi on Ubuntu 20.04 'apt install inxi' and worked like charm. Thanks for that.

  3. As a "frontend" for reading the temperatures from lmsensors AND smartctl (for your SSD) in one pass, I can recommend the dashboard page from Webmin. Plus lot of other info as a bonus...

    1. Hi Remco,

      Thanks. Yes smartctl is an efficient tool for checking the overall health of the Disks.

  4. If you are using KDE, you can install the Temperature Monitor widget, which when configured, will display the CPU temp(s) in the taskbar. Thinkfan is a program to control the fan speeds on Thinkpad laptops

  5. Good article! Both gkrellm and conky can also display sensor information. Plus hddtemp can be used to monitor the temperatures of SSDs and hard drives.

  6. I have a freebsd server as router and i see frequently cpu temperature is spiking. Is ther any tool to check the process by which the temperature spiking?