Maintaining optimal operating temperatures is critical for the stability and longevity of Linux servers and desktop environments. Overheating can lead to aggressive thermal throttling (reducing system performance) or catastrophic hardware failure. While Windows relies heavily on graphical utilities for monitoring, Linux users typically prefer the speed and scriptability of the command line.
This guide explains how to install, configure, and use lm-sensors, the standard Linux utility for monitoring CPU, GPU, and motherboard temperatures directly from the terminal.
Step 1: Install lm-sensors
The lm-sensors package is available in the default repositories of almost all major Linux distributions, but it is rarely installed by default.
For Ubuntu and Debian-based systems:
sudo apt update
sudo apt install lm-sensors
For Fedora and RHEL-based systems:
sudo dnf install lm_sensors
Step 2: Detect Your Hardware Sensors
Installing the package is not enough; you must instruct the utility to scan your motherboard and identify the specific monitoring chips installed by the manufacturer. This is a crucial step.
sudo sensors-detect
The interactive script will ask you a series of questions. It will probe various hardware buses (such as I2C, SMBus, and Super I/O) looking for known sensor chips. For most modern hardware, it is entirely safe to answer YES to every prompt by pressing the Enter key.
At the end of the script, it will ask if you want to automatically add the discovered kernel modules to your /etc/modules file. Type YES to ensure the sensors are loaded automatically upon every reboot.
Step 3: Check System Temperatures
Once detection is complete, checking your current system temperature is incredibly simple.
sensors
The output will display the readings from all detected chips. You will typically see:
- Coretemp: The temperature of individual CPU cores.
- ACPI: General motherboard thermal zones.
- GPU sensors: Usually listed as
amdgpufor AMD graphics ornouveau/nvidiafor NVIDIA hardware. - Fan Speeds: If your motherboard supports it, you will also see the RPM (Revolutions Per Minute) of your CPU and case fans.
Step 4: Monitor Temperatures in Real-Time
Running the sensors command only provides a static snapshot of your temperatures at that exact second. To monitor temperatures dynamically while running stress tests or compiling software, you can combine it with the watch command.
watch -n 1 sensors
This command will refresh the sensor output in your terminal every 1 second (-n 1). To exit the real-time monitoring view, simply press Ctrl + C on your keyboard.
Troubleshooting Missing CPU Temperatures
If you have recently built a PC with a brand-new generation of processors (such as the latest AMD Ryzen or Intel Core series), you might find that sensors outputs very little information, or fails to show CPU temperatures entirely.
This occurs because the sensor drivers for brand-new hardware are integrated directly into the Linux Kernel, not the lm-sensors package itself. If your hardware is newer than your current Linux Kernel version, the system physically cannot read the sensors. To resolve this, you must upgrade your operating system to a newer Kernel version that includes support for your specific architecture.