Introduction
Hardware monitoring is an important task for any Linux system administrator. It allows you to monitor CPU and other component temperatures, CPU load, RAM, disk space, and network interfaces. Timely detection of anomalies helps prevent overheating, failures, and ensures stable operation of a server or workstation. In this guide, you will learn how to set up hardware monitoring in Linux using three popular utilities: lm-sensors, htop, and nmon. After completing the steps, you will be able to track key system parameters in real time.
Requirements / Preparation
Before you begin, ensure you have:
- A Linux distribution that supports the lm-sensors, htop, and nmon packages (e.g., Ubuntu 20.04+, Debian 10+, CentOS 7+, Fedora 30+).
- Terminal access with superuser (sudo) privileges to install packages and configure sensors.
- A stable internet connection to download packages.
Step 1: Install the lm-sensors Package
lm-sensors is a set of utilities for working with hardware sensors for temperature, voltage, and fan speed.
For Ubuntu and Debian:
sudo apt update
sudo apt install lm-sensors
For CentOS, RHEL, and Fedora:
# CentOS 7 / RHEL 7
sudo yum install lm_sensors
# CentOS 8 / RHEL 8 / Fedora
sudo dnf install lm_sensors
Optional: For a graphical interface, you can install psensor:
# Ubuntu/Debian
sudo apt install psensor
# CentOS/Fedora
sudo dnf install psensor
Step 2: Detect and Configure Sensors
After installing lm-sensors, you need to detect the available sensors in your system.
Run the command:
sudo sensors-detect
The program will ask a series of questions. It is recommended to answer YES (or just press Enter) to all prompts to ensure maximum detection. At the end, sensors-detect will suggest loading kernel modules. This is usually done automatically, but if modules failed to load, run:
sudo service kmod start # For Debian/Ubuntu
# or
sudo systemctl restart kmod # For systemd-based systems
In some cases, a system reboot may be required.
Step 3: View Sensor Readings
After configuration, check if the sensors are working:
sensors
Example output:
coretemp-isa-0000
Adapter: ISA adapter
Package id 0: +45.0°C (high = +100.0°C, crit = +100.0°C)
Core 0: +43.0°C (high = +100.0°C, crit = +100.0°C)
Core 1: +44.0°C (high = +100.0°C, crit = +100.0°C)
acpitz-virtual-0
Adapter: Virtual device
temp1: +45.0°C (crit = +119.0°C)
Here you see the CPU temperature (coretemp) and other sensors (e.g., acpitz). A positive value indicates heat, and the critical temperature (crit) is the threshold at which the system may shut down abruptly.
Step 4: Install and Use htop
htop is an interactive process viewer that shows CPU load, memory and swap usage, and a list of running processes.
Installation:
# Ubuntu/Debian
sudo apt install htop
# CentOS/Fedora
sudo dnf install htop
Launch:
htop
In the htop interface:
- The top displays CPU load graphs (each core separately), memory, and swap.
- The center shows a process table with fields: PID, USER, PRIO, NICE, RES, %CPU, %MEM, TIME+, COMMAND.
- The bottom shows a hint line for controls.
Key actions:
- Sort by column: Press F6 and select a field.
- Kill a process: Select it and press F9, then choose a signal (usually SIGTERM).
- Search for a process: Press F3 and enter a name.
- Exit: F10 or q.
htop is excellent for quickly analyzing which process is consuming many resources.
Step 5: Install and Use nmon
nmon (Nigel's Monitor) is a powerful utility that displays many metrics on one screen: CPU, memory, network, disks, filesystems, kernel processes, etc.
Installation:
# Ubuntu/Debian
sudo apt install nmon
# CentOS/Fedora
sudo dnf install nmon
Launch:
nmon
After starting, you will see a screen with hints. Press keys to switch between modes:
c— CPU load (per core)m— memory and swapd— disk I/On— network interfacest— filesystemsk— kernel processesj— filesystem journalr— radiators (temperature, if available)h— help for all keys
To exit, press q.
nmon can also save data to a file for later analysis:
nmon -f -s 2 -c 30 # Record every 2 seconds, 30 times
This creates a file with the .nmon extension, which can be opened with the nmon2rrd or nmonchart tools.
Verify the Result
- For lm-sensors: The
sensorscommand should output current temperature, voltage, and fan speed values. - For htop: When you run
htop, you should see an interactive interface with real-time updating data. - For nmon: When you run
nmon, you can switch between screens using keys and see the dynamics of metrics.
If any tool is not working, review the "Possible Issues" section.
Possible Issues
⚠️ sensors-detect does not detect sensors. Ensure your computer supports hardware sensors (modern PCs and servers usually do). Update your BIOS/UEFI to the latest version. Check if kernel modules are loaded:
lsmod | grep sensor. If not, try loading them manually:sudo modprobe coretemp(for Intel) orsudo modprobe k10temp(for AMD). Runsudo sensors-detect --autoto automatically answer all questions.
⚠️ The sensors command outputs no data or shows "No sensors found". Add the current user to the
videogroup (sensors are often accessible to this group):sudo usermod -aG video $USERand log out and back in. Alternatively, usesudo sensorsto check as root.
⚠️ htop or nmon fail to install. Check if repositories are added to your system (e.g., for CentOS, you may need to enable the EPEL repository:
sudo yum install epel-release). Alternatively, usetop(built-in) orglances(if available in repositories).
⚠️ nmon does not show disk or network data. Ensure you have the necessary kernel modules installed (they are usually present by default). Run nmon with the
-fflag to output to a file and check if data is being recorded.
⚠️ High CPU temperature. Check your cooling system: fan speeds (via sensors), dust on radiators. Ensure the CPU is not overloaded: use htop to find processes with high CPU usage.