How do I get the CPU temperature?

1,584,398

Solution 1

Install lm-sensors Install lm-sensors

sudo apt-get install lm-sensors 

After installation type the following in terminal

sudo sensors-detect

You may also need to run

sudo service kmod start

It will ask you few questions. Answer Yes for all of them. Finally to get your CPU temperature type sensors in your terminal.

sensors

Output:

$ sensors
coretemp-isa-0000
Adapter: ISA adapter
Core 0:      +41.0°C  (high = +78.0°C, crit = +100.0°C)  

coretemp-isa-0001
Adapter: ISA adapter
Core 1:      +41.0°C  (high = +78.0°C, crit = +100.0°C)  

w83627dhg-isa-0290
Adapter: ISA adapter
Vcore:       +1.10 V  (min =  +0.00 V, max =  +1.74 V)   
in1:         +1.60 V  (min =  +1.68 V, max =  +1.44 V)   ALARM
AVCC:        +3.30 V  (min =  +2.98 V, max =  +3.63 V)   
VCC:         +3.28 V  (min =  +2.98 V, max =  +3.63 V)   
in4:         +1.85 V  (min =  +1.66 V, max =  +1.11 V)   ALARM
in5:         +1.26 V  (min =  +1.72 V, max =  +0.43 V)   ALARM
in6:         +0.09 V  (min =  +1.75 V, max =  +0.62 V)   ALARM
3VSB:        +3.30 V  (min =  +2.98 V, max =  +3.63 V)   
Vbat:        +3.18 V  (min =  +2.70 V, max =  +3.30 V)   
fan1:          0 RPM  (min = 10546 RPM, div = 128)  ALARM
fan2:        892 RPM  (min = 2136 RPM, div = 8)  ALARM
fan3:          0 RPM  (min = 10546 RPM, div = 128)  ALARM
fan4:          0 RPM  (min = 10546 RPM, div = 128)  ALARM
fan5:          0 RPM  (min = 10546 RPM, div = 128)  ALARM
temp1:       +36.0°C  (high = +63.0°C, hyst = +55.0°C)  sensor = diode
temp2:       +39.5°C  (high = +80.0°C, hyst = +75.0°C)  sensor = diode
temp3:      +119.0°C  (high = +80.0°C, hyst = +75.0°C)  ALARM  sensor = thermistor
cpu0_vid:   +2.050 V

To see HDD temperature Install hddtemp Install hddtemp

sudo apt-get install hddtemp

Output:

$ sudo hddtemp /dev/sda        
/dev/sda: ST3160813AS: 34°C

Solution 2

Quick command-line solution; shows temperature in millidegrees Celsius (m°C)

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

Applet

If you are looking for a easier-to-access version, add a Hardware Sensors Monitor to Gnome-Panel:

  1. sudo apt-get install sensors-applet - this will install the sensors-applet Install sensors-applet package
  2. Right-click the panel, select Add to panel..., then select this: alt text

  3. You're done. You can configure which sensors are displayed by right-clicking the applet and selecting Preferences->Sensors.

    alt text

Solution 3

A good indicator for monitoring temperature, fan speeds and voltage is psensor. It shows output of all sensors, draws graphs. Also selected outputs can be placed in indicator panel.

psensor in action

It can be installed from Ubuntu repositories by typing:

sudo apt-get install psensor

Newer versions of psensor can be installed from ppa:

sudo add-apt-repository ppa:jfi/ppa
sudo apt-get update
sudo apt-get install psensor

It can also draw graphs when you tick the boxes in the graph column:

Screenshot

Here is some information with more pictures.

Another useful link

In some cases not all sensors are displayed. Then you can run

sudo sensors-detect

and answer "yes" to all questions. But is not quite safe in some cases, but I never had any real problems with that. A safer way is to take default answers.

Some additional sensors may appear.

Solution 4

Temperature without third-party apps

At the time of writing, all the answers involve use of third-party utilities. If you want to find out the temperature without installing anything, use:

$ cat /sys/class/thermal/thermal_zone*/temp
20000
53000
50000
53000
56000
68000
49000
50000

To see what zones the temperatures are referring to use:

$ paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) | column -s $'\t' -t | sed 's/\(.\)..$/.\1°C/'
INT3400 Thermal  20.0°C
SEN1             45.0°C
SEN2             51.0°C
SEN3             57.0°C
SEN4             59.0°C
pch_skylake      77.5°C
B0D4             50.0°C
x86_pkg_temp     51.0°C

The temperatures are stored in Celsius with 3 implied decimal places. sed is used to "prettify" output.

The last temperature is x86_pkg_temp reported at 54.0°C. For the Skylake i7 6700HQ CPU, I used this temperature for Conky display below.

Temperature with Conky

If you don't mind third-party utilities I like to use Conky--a light weight system monitor.

Conky commands

Within conky the system variable I used to monitor an Ivy Bridge CPU is:

${hwmon 2 temp 1}°C

To monitor a Skylake CPU I used:

${hwmon 0 temp 1}°C

Conky display

The conky display looks like this:

enter image description here

The temperature starts at 72°C with a single CPU running at 100% in turbo mode of 3200 MHz. Then turbo is switched off and temp drops 10°C to 62°C with a non-turbo speed of 2600 MHz. 10 seconds later turbo is turned back on and temperatures immediately spike back up to 72°C.


Controlling Temperature

After knowing your temperature you probably want to control it better. tlp works wonders for keeping system under control. It works with thermald, Intel Powerclamp, Battery vs AC for USB power, etc. Although highly configurable I've never had to change the configuration settings for a pleasant Out-Of-The-Box experience. Prior to using it I had all kinds of problems with an IvyBridge laptop overheating all the time. I have it on my new Skylake laptop and the fans NEVER run except when doing Ubuntu 16.04 LTS to 18.04 upgrade.

You can get a very detailed write-up with installation instructions here: Stop cpu from overheating

Solution 5

hardinfo Install hardinfo is very useful tools to get all hardware information.

Install hard info by sudo apt-get install hardinfo. Then you can get temperature by sensors.

sensor

Share:
1,584,398

Related videos on Youtube

trampster
Author by

trampster

Updated on September 18, 2022

Comments

  • trampster
    trampster over 1 year

    How do I get the CPU temperature?

  • karthick87
    karthick87 over 13 years
    Your command-line solution may not work for all.Because the path will be different for every kernel version.
  • Code.Decode
    Code.Decode almost 12 years
    Yeah it didn't work for me.
  • Keith Thompson
    Keith Thompson over 11 years
    This doesn't work on all hardware. On my system, sensors always shows a temperature of +40.0°C.
  • Keith Thompson
    Keith Thompson over 11 years
    My Ubuntu 12.04 system has no /proc/acpi/thermal_zone/THRM/temperature; in fact there's nothing under /proc named temperature.
  • knb
    knb almost 11 years
    On my 13.04 system, it's sudo service kmod start instead of sudo service module-init-tools start
  • LAFK says Reinstate Monica
    LAFK says Reinstate Monica almost 11 years
    +1 for quick command line option. Answer would benefit from adding more info about it (@mathepic comment and info about other paths possible).
  • Drew Noakes
    Drew Noakes over 10 years
    You can run watch sensors to see temperature values updating each second.
  • stommestack
    stommestack over 10 years
    It gives warnings about being risky. Are you sure you should answer "yes" to everything? I don't think they have put those messages there for fun...
  • fikr4n
    fikr4n over 10 years
    This is simpler than the answers about lm-sensors. Could you explain the difference between acpi and lm-sensors?
  • Deepak Verma
    Deepak Verma almost 10 years
    for my 14.04 system, neither command line works (No such file or directory).
  • PythoNic
    PythoNic almost 10 years
    @mathepic: why is it depracted? and is /sys/... still (like proc) containing zero-sized on-demand files?
  • PythoNic
    PythoNic almost 10 years
    Since adding panels didn't work, I went to extensions.gnome.org to find something alike.
  • e-sushi
    e-sushi over 9 years
    Right… because you don’t have to install that one? Wrong! The program 'acpi' is currently not installed. You can install it by typing: sudo apt-get install acpi
  • frumbert
    frumbert about 9 years
    Good looking tool, except every single page populates except Sensors (e.g. is blank)...
  • Mudit Kapil
    Mudit Kapil about 9 years
    not working for Sensors
  • Nicolas Ivanov
    Nicolas Ivanov almost 9 years
    in Ubuntu 15.04 sudo apt-get install computertemp results in the error "Unable to locate package computertemp" ...
  • spharish
    spharish almost 9 years
    What are the three temperatures temp1, temp2, temp3? @karthick87 ?
  • niceman
    niceman over 8 years
    I notice you have problems in your computer(many ALARMS), anyway I want to ask, what are in4 in5 in6 and if the reach the maximum what does that mean ?
  • Per Lundberg
    Per Lundberg over 8 years
    And, it also doesn't always give the same information. On my machine, sensors provides the temperature whereas acpi -V doesn't show anything about it, unfortunately.
  • Joshua K
    Joshua K over 8 years
    i like the tip about using watch, it's one of my favorites. i also recommend adding the -d option to watch to highlight the differences.
  • dylnmc
    dylnmc about 8 years
    what units for cat /sys/class/thermal/thermal_zone0/temp? Can you convert it to C/F? ... Looks like the first two digits are the first two digits preceding the decimal place and the next are those following the decimal place for Celsius.
  • Peter Novotnak
    Peter Novotnak about 8 years
    @mathepic procfs is not depreciated, using it for non-process information is.
  • Karsus
    Karsus almost 8 years
    I got an answer 66000 running the command as given in the answer on fully updated 16.04.
  • Karsus
    Karsus almost 8 years
    @Peter Mortensen: Mine has thermal_zone0, cooling_device0 ... cooling_device8. I 'd guess it's probably the different hardware/firmware that makes the OS create these folders in different ways? (Just guessing.)
  • Pandya
    Pandya over 7 years
    @frumbert I think it depends on lm-sensors!
  • alhelal
    alhelal over 7 years
    This work for me , but I don't understand the output. The output is : 53500 .What is the meaning of it.
  • MrD
    MrD over 7 years
    No, that will give you the frequency. Use vcgencmd measure_temp
  • MainActivity
    MainActivity over 7 years
    Psensor seems to be more advanced
  • Jordan
    Jordan about 7 years
    @BandaMuhammadAlHelal These guys explain it a bit more. cyberciti.biz/faq/… (basically your temp is 53c)
  • WinEunuuchs2Unix
    WinEunuuchs2Unix about 7 years
    Thermal Zones 0 and 1 are often distorted on my Ubuntu 16.04 Kernel 4.4+ and only Thermal Zone 2 (invisible to sensors) is consistently accurate.
  • Katu
    Katu about 7 years
    I've tried 4 machines in different locations and they all give the same reading = 27800. Do you know why this could be? They can't all have the same cpu temp.
  • Edgar Magallon
    Edgar Magallon about 7 years
    @Katu I think that might mean 27.8 degrees. I used another program and found my Core 0 was 49 C. Then I did the above command and got 49000.
  • Hrvoje T
    Hrvoje T almost 7 years
    In 2017. with systemd, it is now: sudo systemctl start kmod
  • SDsolar
    SDsolar almost 7 years
    I agree, @Serge. psensor is the one I am going to use.
  • SDsolar
    SDsolar almost 7 years
    The only output I get from the sensors command is the temp of the two cores.
  • karel
    karel almost 7 years
    I also use Psensor.
  • SDsolar
    SDsolar almost 7 years
    This did not show up to be added in Ubuntu 16.04 LTS in July 2017. So I uninstalled it then did a sudo apt-get autoremove
  • SDsolar
    SDsolar almost 7 years
    I also like the ARP table. Pretty handy to verify what is connected to my subnet.
  • phil294
    phil294 over 6 years
    what unit is this? apples? 1/1000th of °C? 59/29402th of °F?
  • dirkjot
    dirkjot over 6 years
    On my Ubuntu 16.04, psensor will sometimes use 30% cpu, driving the temperature up.
  • hanshenrik
    hanshenrik over 6 years
    to answer yes to all sensors-detect questions, run yes yes | sensors-detect
  • wjandrea
    wjandrea about 6 years
    I have it on Python 2 but it doesn't have a sensors_temperatures attribute, and I don't have it on Python 3. I'm using Ubuntu 14.04. So how do I get it?
  • Lucas Aimaretto
    Lucas Aimaretto about 6 years
    what version of psutil are you using? mine is 5.4.3. Try upgrading you version: sudo pip2 install psutil --upgrade.
  • wjandrea
    wjandrea about 6 years
    I'm using 1.2.1 on Python 2, and the upgrade fails (but Python 2 on 14.04 is really outdated, so I'm not concerned). I just installed 5.4.3 on Python 3 with sudo pip3 install psutil --upgrade. Could you add that to your answer?
  • wjandrea
    wjandrea about 6 years
    On that plot, the x-axis is CPU usage, right?
  • Lucas Aimaretto
    Lucas Aimaretto about 6 years
    Done the update of the answer. Yes, the X axis is CPU usgae: I'm having trouble with a laptop: is heating a lot (+65°C) with very low CPU (aprox 5%)
  • Eugene
    Eugene about 6 years
    The problem still persists. App is unusable.
  • Andriy Makukha
    Andriy Makukha about 6 years
    Benchmarks are quite outdated in this program though.
  • Kanchu
    Kanchu about 6 years
    A more understandable output: cat /sys/class/thermal/thermal_zone*/temp | awk '{ print ($1 / 1000) "°C" }'
  • muru
    muru about 6 years
    Why echo $(printf ..) and not just printf '%d°\n' $(sensors | grep 'id 0:' | awk '{ print $4 }') 2>/dev/null? ... Or even just sensors 2>/dev/null | awk '/id 0:/{printf "%d°\n", $4}'
  • intika
    intika about 6 years
    Yes, a lot of possibility, i just posted the one i was using
  • Ercksen
    Ercksen about 6 years
    Sorry, a very painful copy & paste mistake :)
  • WinEunuuchs2Unix
    WinEunuuchs2Unix almost 6 years
    On Ubuntu 16.04, Skylake Laptop, acpi -t outputs nothing. It's a valid option, just doesn't work--version: acpi 1.7.
  • WinEunuuchs2Unix
    WinEunuuchs2Unix almost 6 years
    acpi -V is broken for Skylake laptop, Ubuntu 16.04, acpi version 1.7
  • Sun
    Sun almost 6 years
    your quote says 48000 but your text says this is 57 degrees Celsius? I'm confused.
  • Sun
    Sun almost 6 years
    This gave me 4 core temp reading on my i7-3770 on Ubuntu 16.0.4 LTS running 100% CPU (~77 degrees Celsius)
  • WinEunuuchs2Unix
    WinEunuuchs2Unix almost 6 years
    @Sun I had regenerated the one-liner using a newer processor and didn't revise the explanation properly. Fixed!
  • reducing activity
    reducing activity almost 6 years
    @raaj - is this bug reported somewhere?
  • reducing activity
    reducing activity almost 6 years
    @Eugene - is this bug reported somewhere?
  • SDsolar
    SDsolar almost 6 years
    Ubuntu 16.04 LTS already has this installed, although the output of the sensors command is much more brief.
  • ablaze
    ablaze almost 6 years
    Works for me! Also shows me a graph in green color at the bottom. This tool is by far the best!
  • ncoghlan
    ncoghlan over 5 years
    Slight tweak to the sed command to get it to handle fractions of a degree: sed 's/\(.\)..$/.\1°C/'
  • ncoghlan
    ncoghlan over 5 years
    I'm wondering if there may sometimes be an extra step needed to get the kernel to actually read the board temperature sensors, as I'm currently getting 26.8 degrees for both a unit in my lab, and one out in the field, and I frankly don't believe the one in the field could be running that cool when the modem next to it is reporting a temperature of 42 degrees (similar to @Katu askubuntu.com/questions/15832/how-do-i-get-the-cpu-temperatu‌​re/… here)
  • WinEunuuchs2Unix
    WinEunuuchs2Unix over 5 years
    @ncoghlan I've noticed the same thing when room temperature is 25C but sensor INT3400 Thermal always reports an impossible 20C. I simply ignore that sensor...
  • Rajat
    Rajat over 5 years
    After installing this my touch pad stops working at periodic times
  • Philippe Delteil
    Philippe Delteil about 5 years
    It's actually a pretty good script.
  • Daniel Böhmer
    Daniel Böhmer about 5 years
    I successfully used acpi -t on grml live CD system to monitor the temperature of each die of an Core i3 processor. lm-sensors isn't preinstalled on grml and I can't install other packages there. grml.org
  • WoJ
    WoJ almost 5 years
    great answer (+1) - psutil is a gem. It is ashame it does not cover the HDD temperature
  • jocull
    jocull over 4 years
    Is there a way to install this on other distros besides Raspbian? For example, Ubuntu Server 19.10 is available for Raspberry Pi, but I'm not aware of how make this command available.
  • Philippe Paré
    Philippe Paré over 4 years
    and for the gpu?
  • igagis
    igagis almost 4 years
    it was at /sys/devices/platform/coretemp.0/hwmon/hwmon*/temp*_input on my Dell Precision M4800
  • wes
    wes over 3 years
    What are recommended temperatures for components? Or rather, what temperatures should make me worried?
  • Peeyush Kushwaha
    Peeyush Kushwaha over 3 years
    My system froze when I answered "yes" to one of the questions (about probing various I/O ports). Anyways, it had detected correct sensors for what I had wanted already so I just answered no to everything else and it still worked fine.
  • Íhor Mé
    Íhor Mé over 3 years
    The only answer that worked. (Ubuntu 20.04) And almost the only one that didn't require installing anything.
  • Trect
    Trect over 3 years
    run watch -n 0.1 sensors to check every 0.1 second
  • Max Malysh
    Max Malysh over 3 years
    Didn't work for me: psutil.sensors_temperatures() returns {}.
  • Steven Lu
    Steven Lu over 3 years
    acpi just fails with No support for device type: power_supply for me.
  • Jim Raynor
    Jim Raynor about 3 years
    Thanks! And this is a bit off-topic, but how do you create a (such high-quality) GIF capturing a portion of the screen like that?
  • WinEunuuchs2Unix
    WinEunuuchs2Unix about 3 years
    @JimRaynor The area is called screen recording and there is a Q&A about that here: askubuntu.com/questions/4428/how-can-i-record-my-screen I'm using peek which you will find instructions for on the link.
  • Rohit Parte
    Rohit Parte over 2 years
    This worked very well!
  • seeker_of_bacon
    seeker_of_bacon about 2 years
    Wow, you were NOT kidding! I thought I was going into hyperspace when I first saw that loading screen :)
  • Ray Woodcock
    Ray Woodcock about 2 years
    By default, psensor detected only two cores on a quad-core CPU. Odd.