Исходный код вики How to check CPU temperature on Ubuntu Linux
Редактировал(а) Сергей Коршунов 2022/06/16 12:32
Последние авторы
author | version | line-number | content |
---|---|---|---|
1 | How do I check CPU temperature in Ubuntu Linux using a command line and GUI tools on my Thinkpad laptop or Desktop computer? | ||
2 | \\One of the most common complaints is the overheating laptop, especially older models. Laptop components are tightly put together to each other. So there is very little room for air movement in thinner laptops. If your laptop overheats, it can cause some damage to your body as well as the hardware parts. Therefore monitoring hardware temperature is essential. In this tutorial, you will learn how to check CPU temperature in Ubuntu Linux. | ||
3 | |||
4 | |=(% colspan="2" %)Tutorial details | ||
5 | |Difficulty level|[[Easy>>url:https://www.cyberciti.biz/faq/tag/easy/]] | ||
6 | |Root privileges|[[Yes>>url:https://www.cyberciti.biz/faq/how-can-i-log-in-as-root/]] | ||
7 | |Requirements|Linux terminal | ||
8 | |OS compatibility|[[Debian>>url:https://www.cyberciti.biz/faq/category/debian-ubuntu/]] • Mint • Pop!_OS • [[Ubuntu>>url:https://www.cyberciti.biz/faq/category/ubuntu-linux/]] | ||
9 | |Est. reading time|4 minutes | ||
10 | |||
11 | Advertisement | ||
12 | |||
13 | == Procedure for monitoring CPU and HDD temperatures on Ubuntu == | ||
14 | |||
15 | 1. Open the terminal application. | ||
16 | 1. Install the lm-sensors and hddtemp packages in Ubuntu using the following command: | ||
17 | **sudo apt install hddtemp lm-sensors** | ||
18 | 1. Run **hddtemp** command to see SSD and hard drive temperature in Ubuntu. | ||
19 | 1. Execute **sensors** command to find out CPU temperature in Ubuntu Linux. | ||
20 | |||
21 | Let us view processor temperature including SSD/HDD in details for Ubuntu desktop or server with configurations. | ||
22 | |||
23 | == Check CPU temperature in Ubuntu Linux == | ||
24 | |||
25 | The sensors command is used in Linux to show the current readings of all sensor chips including CPU temp. The hddtemp command will show you the temperature for SSD and HDD. You need to install and configure the lm-sensors package as well as hddtemp. You can search it using the following syntax: | ||
26 | apt-cache search lm-sensors | ||
27 | apt-cache search hddtemp | ||
28 | [[image:https://www.cyberciti.biz/media/new/faq/2019/08/Check-CPU-and-HDD-temp-packages-in-Ubuntu-Linux.png||alt="Check CPU and HDD temp packages in Ubuntu Linux" height="424" width="599"]] | ||
29 | To install these packages on Ubuntu, run the following [[apt command>>url:https://www.cyberciti.biz/faq/ubuntu-lts-debian-linux-apt-command-examples/?utm_source=Linux_Unix_Command&utm_medium=faq&utm_campaign=nixcmd]] or [[apt-get command>>url:https://www.cyberciti.biz/tips/linux-debian-package-management-cheat-sheet.html?utm_source=Linux_Unix_Command&utm_medium=faq&utm_campaign=nixcmd]] in a terminal: | ||
30 | sudo apt update | ||
31 | sudo apt upgrade | ||
32 | |||
33 | === Install lm-sensors in Ubuntu Linux === | ||
34 | |||
35 | Type the following [[apt command>>url:https://www.cyberciti.biz/faq/ubuntu-lts-debian-linux-apt-command-examples/?utm_source=Linux_Unix_Command&utm_medium=faq&utm_campaign=nixcmd]]: | ||
36 | sudo apt install lm-sensors | ||
37 | [[image:https://www.cyberciti.biz/media/new/faq/2019/08/How-to-install-lm-sensors-on-Ubuntu-Linux.png||alt="How to install lm-sensors on Ubuntu Linux" height="450" width="599"]] | ||
38 | Next you need to detect hardware monitoring chips installed in your laptop. Hence, start the detection of your laptop hardware sensors that will provide information about: | ||
39 | |||
40 | * Sensors embedded in CPUs and other super I/O chips | ||
41 | * Hardware monitoring chips accessed through I/O ports and SMBus/I2C bus on your system | ||
42 | |||
43 | Type the following command: | ||
44 | sudo sensors-detect | ||
45 | [[image:https://www.cyberciti.biz/media/new/faq/2019/08/Ubuntu-Linux-detect-hardware-monitoring-chips.png||alt="Ubuntu Linux detect hardware monitoring chips" height="321" width="599"]] | ||
46 | |||
47 | === Display CPU temperature in the command line === | ||
48 | |||
49 | Execute the following command: | ||
50 | sensors | ||
51 | [[image:https://www.cyberciti.biz/media/new/faq/2019/08/See-CPU-temperature-in-Ubuntu-Linux-using-the-command-line-option.png||alt="See CPU temperature in Ubuntu Linux using the command line option" height="543" width="599"]] | ||
52 | One can use the watch command command to run sensors command repeatedly, displaying its output on screen: | ||
53 | watch sensors | ||
54 | |||
55 | === How can I show the CPU temperature in the GNOME panel === | ||
56 | |||
57 | |||
58 | Install [[Freon>>url:https://extensions.gnome.org/extension/1180/freon/]] and [[Sensors>>url:https://extensions.gnome.org/extension/82/cpu-temperature-indicator/]] extension for Ubuntu Linux desktop: | ||
59 | [[image:https://www.cyberciti.biz/media/new/faq/2019/07/sensors-gui.png||alt="Shows CPU temperature, HDD temperature, voltage and fan RPM" height="749" width="285"]] | ||
60 | |||
61 | === How to install hddtemp in Ubuntu Linux === | ||
62 | |||
63 | Run the following [[apt command>>url:https://www.cyberciti.biz/faq/ubuntu-lts-debian-linux-apt-command-examples/?utm_source=Linux_Unix_Command&utm_medium=faq&utm_campaign=nixcmd]]: | ||
64 | sudo apt install hddtemp | ||
65 | [[image:https://www.cyberciti.biz/media/new/faq/2019/08/How-to-install-hddtemp-on-Ubuntu-Linux.png||alt="How to install hddtemp on Ubuntu Linux" height="413" width="599"]] | ||
66 | |||
67 | === How to see hard disk temperature in Ubuntu === | ||
68 | |||
69 | Simply type: | ||
70 | hddtemp | ||
71 | sudo hddtemp SATA:/dev/sda | ||
72 | Sample outputs: | ||
73 | |||
74 | {{{/dev/sda: Samsung SSD 850 EVO 500G: 32°C}}} | ||
75 | |||
76 | === Use disks & storage GUI tool to view hard disk temp === | ||
77 | |||
78 | Hard disks have a built-in health-check tool called SMART (Self-Monitoring, Analysis, and Reporting Technology), which continually checks the disk for potential problems. SMART also warns you if the disk is about to fail, helping you avoid loss of important data. It also displays hard disk temperature. Run: | ||
79 | gnome-disks | ||
80 | [[image:https://www.cyberciti.biz/media/new/faq/2019/08/Monitoring-hard-disk-Temperatures-on-Ubuntu-Linux-with-GUI-tool.png||alt="Monitoring hard disk Temperatures on Ubuntu Linux with GUI tool" height="416" width="599"]] | ||
81 | |||
82 | == How to monitor Nvme ssd temperature in Ubuntu == | ||
83 | |||
84 | First install nvme-cli, run: | ||
85 | sudo apt install nvme-cli | ||
86 | Now use the nvme command as follows to get list of all NVMe devices and namespaces on machine: | ||
87 | sudo nvme list | ||
88 | Sample outputs: | ||
89 | |||
90 | {{{Node SN Model Namespace Usage Format FW Rev | ||
91 | ---------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- -------- | ||
92 | /dev/nvme0n1 S3EUNX0JXXXXXXH Samsung SSD 960 EVO 500GB 1 36.53 GB / 500.11 GB 512 B + 0 B 2B7QCXE7}}} | ||
93 | |||
94 | |||
95 | sudo nvme smart-log /dev/nvme0 | ||
96 | One can filter output using the [[grep command>>url:https://www.cyberciti.biz/faq/howto-use-grep-command-in-linux-unix/?utm_source=Linux_Unix_Command&utm_medium=faq&utm_campaign=nixcmd]]: | ||
97 | sudo nvme smart-log /dev/nvme0 | grep temperature | ||
98 | |||
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. |