Changes for page How to check CPU temperature on Ubuntu Linux
Last modified by Сергей Коршунов on 2022/06/16 12:32
From version 1.1
edited by Сергей Коршунов
on 2022/06/16 09:31
on 2022/06/16 09:31
Change comment:
There is no comment for this version
To version 2.1
edited by Сергей Коршунов
on 2022/06/16 12:32
on 2022/06/16 12:32
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -97,3 +97,149 @@ 97 97 sudo nvme smart-log /dev/nvme0 | grep temperature 98 98 99 99 {{{temperature : 40 C}}} 100 + 101 + 102 +Introduction 103 + 104 +Like any electrical component, CPUs generate heat when being used. Some resource-demanding programs cause the CPU to increase the clock speed, which results in higher temperatures. Dust buildup also causes the CPU to overheat. 105 + 106 +High temperatures shorten the lifespan of sensitive components, so keeping track of CPU temperatures is crucial. This way, you prevent performance throttling or component damage. 107 + 108 +**In this tutorial, you will learn how to use different tools and in-built utilities to check CPU temperature on Linux machines.** 109 + 110 +[[image:https://phoenixnap.com/kb/wp-content/uploads/2021/04/How-to-Check-CPU-Temperature-on-Linux.png||alt="How to Check CPU Temperature on Linux" height="400" width="800"]] 111 + 112 +Prerequisites 113 + 114 +* A machine running Linux 115 +* An account with sudo/root privileges 116 + 117 +== Check CPU Temperature Using Lm-Sensors == 118 + 119 +**Lm-sensors** is a command-line utility for hardware monitoring. Use the tool to check the temperature of the CPU and other components. Follow these steps to install and configure Lm-sensors: 120 + 121 +~1. Open the terminal and install these packages using a package manager for your distribution. In Ubuntu, use the following command: 122 + 123 +{{{sudo apt install hddtemp lm-sensors}}} 124 + 125 +Wait for the **lm-sensors** and **hddtemp** to finish downloading and installing. 126 + 127 +2. Execute the **sensors** command to see the CPU temperature. The output shows the current temperature readings of all sensors in the machine. The results include the temperature of each core and maximum thresholds. 128 + 129 +[[image:https://phoenixnap.com/kb/wp-content/uploads/2021/04/sensors.png||alt="Sensors command output on Linux Ubuntu." height="330" width="800"]] 130 + 131 +3. To check SSD and hard drive temperatures, execute the following command: 132 + 133 +{{{sudo hddtemp /dev/sda}}} 134 + 135 +[[image:https://phoenixnap.com/kb/wp-content/uploads/2021/04/hddtemp.png||alt="Check hard drive temperature on Linux Ubuntu." height="80" width="800"]] 136 + 137 +The output shows the temperature of the selected disk. 138 + 139 +4. To see which system components you can monitor, run **sudo sensors-detect**. 140 + 141 +Answer **YES** to multiple scanning requests until the system scan is complete. 142 + 143 +[[image:https://phoenixnap.com/kb/wp-content/uploads/2021/04/sensors-detect-output.png||alt="Output showing a summary of sensors detected on Ubuntu." height="400" width="800"]] 144 + 145 +When the scan completes, the output shows the summary. 146 + 147 +5. To ensure that system monitoring works, load the needed modules using the following command: 148 + 149 +{{{/etc/init.d/kmod start}}} 150 + 151 +[[image:https://phoenixnap.com/kb/wp-content/uploads/2021/04/etc-init.d.png||alt="Start kmod service on Ubuntu to monitor hardware temperature." height="60" width="800"]] 152 + 153 +6. To run the **sensors** command repeatedly and get real-time data in the terminal, execute the following command: 154 + 155 +{{{watch sensors}}} 156 + 157 +[[image:https://phoenixnap.com/kb/wp-content/uploads/2021/04/watch-sensors.png||alt="Real-time output in terminal showing CPU temperature on Ubuntu." height="350" width="800"]] 158 + 159 +The output refreshes every two seconds and displays the current CPU temperature reading. 160 + 161 +**Note: **To check CPU usage on Linux, read our tutorial on [[How to check CPU usage>>url:https://phoenixnap.com/kb/check-cpu-usage-load-linux]]. 162 + 163 +== Check CPU Temperature Using Psensor == 164 + 165 +Psensor is a **GUI app** that allows you to monitor the temperature of various system components. This utility also allows you to monitor CPU usage and fan speed. 166 + 167 +Psensor includes an applet indicator for Ubuntu, allowing you to display the temperature in the top panel to notify you when the temperatures get too high. 168 + 169 +=== Install Psensor === 170 + 171 +Before installing Psensor, you need to install and configure Lm-sensors. 172 + 173 +~1. Run this command to install the necessary packages: 174 + 175 +{{{sudo apt install lm-sensors hddtemp}}} 176 + 177 +2. Next, scan for sensors in your machine: 178 + 179 +{{{sudo sensors-detect}}} 180 + 181 +Answer **YES** to any scan requests until the scan is completed. 182 + 183 +3. To make sure the packages are installed, execute the **sensors** command. 184 + 185 +[[image:https://phoenixnap.com/kb/wp-content/uploads/2021/04/sensors.png||alt="Sensors command output on Linux Ubuntu." height="330" width="800"]] 186 + 187 +4. Update the package repository with **sudo apt update**. 188 + 189 +5. Install Psensor using the following command: 190 + 191 +{{{sudo apt install psensor}}} 192 + 193 +[[image:https://phoenixnap.com/kb/wp-content/uploads/2021/04/install-psensor.png||alt="Install Psensor app on Ubuntu Linux." height="230" width="800"]] 194 + 195 +Answer **YES** and wait for the installation to finish. 196 + 197 +=== Using Psensor === 198 + 199 +Search for **Psensor **in the app menu and open the utility. The app displays a graph of the selected values and shows the CPU temperature, CPU and memory usage, free RAM, GPU temperature, and HDD temperature. 200 + 201 +[[image:https://phoenixnap.com/kb/wp-content/uploads/2021/04/psensor-graph.png||alt="Psensor app on Ubuntu showing hardware temperatures." height="280" width="800"]] 202 + 203 +To configure Psensor and set which stats you want to see, follow these steps: 204 + 205 +~1. Click **Psensor** in the menu bar, followed by **Preferences**. 206 + 207 +2. Check off the boxes for the options you want – whether Psensor launches on system startup, the update interval, graph colors, etc. 208 + 209 +[[image:https://phoenixnap.com/kb/wp-content/uploads/2021/04/psensor-preferences.png||alt="Psensor app Preferences on Ubuntu Linux." height="508" width="502"]] 210 + 211 +3. To show CPU or HDD temperatures in the top panel, go to **Sensor Preferences** under the **Application Indicator.** Enable the **Display sensor in the label **option. 212 + 213 +[[image:https://phoenixnap.com/kb/wp-content/uploads/2021/04/sensor-preferences-1.png||alt="Display sensor output in the top label in Ubuntu." height="336" width="684"]] 214 + 215 +== Check Temperature Without Third-Party Utilities == 216 + 217 +There is a way to use the in-built utilities to check the CPU temperature if you don’t want to use third-party apps. 218 + 219 +~1. To check the CPU temperature without installing a third-party app, use the following command: 220 + 221 +{{{cat /sys/class/thermal/thermal_zone*/temp}}} 222 + 223 +[[image:https://phoenixnap.com/kb/wp-content/uploads/2021/04/cat-sys-class.png||alt="Display CPU temperature in Ubuntu without third-party apps." height="50" width="800"]] 224 + 225 +The output shows the CPU temperature in the five-digit format. Here, 49000 means 49C. 226 + 227 +2. If you get several thermal zones and different temperatures, execute the following command to see what a single thermal zone represents: 228 + 229 +{{{cat /sys/class/thermal/<thermal_zoneNumber>/type}}} 230 + 231 +For example, run **cat /sys/class/thermal/thermal_zone2/type** to see the type of thermal zone 2. 232 + 233 +The CPU temperature is in the zone labeled **x86_pkg_temp**. 234 + 235 +3. To see what all the thermal zones are referring to, use: 236 + 237 +{{{paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) | column -s $'\t' -t | sed 's/\(.\)..$/.\1°C/'}}} 238 + 239 +[[image:https://phoenixnap.com/kb/wp-content/uploads/2021/04/paste-cat.png||alt="Display CPU temperature in Ubuntu without third-party apps." height="80" width="800"]] 240 + 241 +The output shows the last stored temperature for that thermal zone in degrees Celsius. In this example, there is only one thermal zone, labeled **x86_pkg_temp**, which represents the CPU temperature. 242 + 243 +Conclusion 244 + 245 +You now know how to check CPU temperature on Linux using various utilities. The guide also showed how to configure the tools to display other information, such as GPU and HDD temperature.