Table of Contents#
- Introduction
- 1. lm-sensors: The Foundation of Hardware Monitoring
- 2. htop: Real-Time Process and Resource Monitoring
- 3. Glances: All-in-One System Monitoring
- 4. iostat: Disk I/O Performance Analysis
- 5. nvtop: GPU Monitoring for NVIDIA/AMD
- 6. smartctl: Storage Health with S.M.A.R.T.
- 7. Psensor: Graphical Hardware Monitoring
- 8. collectl: Advanced System Data Logging
- Conclusion
- References
1. lm-sensors: The Foundation of Hardware Monitoring#
Overview#
lm-sensors (Linux Monitoring Sensors) is a CLI tool that reads data from hardware sensors embedded in your motherboard, CPU, GPU, and other components. It’s the backbone for many other monitoring tools, providing low-level access to temperatures, fan speeds, and voltage levels.
Installation#
Install lm-sensors on major Linux distributions:
-
Debian/Ubuntu:
sudo apt update && sudo apt install lm-sensors -
Fedora/RHEL:
sudo dnf install lm-sensors -
Arch Linux:
sudo pacman -S lm-sensors
Basic Usage#
-
Detect Sensors: After installation, run
sensors-detectto identify hardware sensors. Answer "Yes" to most prompts (safe for typical systems):sudo sensors-detect -
View Sensor Data: Run
sensorsto display real-time readings:sensorsExample 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) nvme-pci-0200 Adapter: PCI adapter Composite: +38.9°C (low = -273.1°C, high = +77.8°C)
Key Features#
- Monitors CPU/GPU temperatures, fan speeds, and voltages.
- Lightweight and minimal resource usage.
- Supports most modern motherboards and CPUs (Intel/AMD).
2. htop: Real-Time Process and Resource Monitoring#
Overview#
htop is an enhanced alternative to the classic top command. It provides a colorful, interactive dashboard for monitoring CPU, memory, and process activity in real time. Unlike top, htop supports mouse input and vertical/horizontal scrolling.
Installation#
-
Debian/Ubuntu:
sudo apt install htop -
Fedora/RHEL:
sudo dnf install htop -
Arch Linux:
sudo pacman -S htop
Basic Usage#
Launch htop with:
htop Interface Breakdown:
- CPU/Memory Bars: Color-coded bars show usage (green = user processes, blue = low-priority, red = kernel).
- Process List: Sorted by CPU usage by default; press
F6to sort by memory, PID, or other metrics. - Key Shortcuts:
F1: Help menu.F9: Kill a process (select with arrow keys, then pressF9and enter signal).F5: Toggle tree view (show parent/child processes).
Key Features#
- Real-time updates (default: 1 second).
- Visual indicators for CPU cores, memory, and swap usage.
- Interactive process management (kill, renice).
3. Glances: All-in-One System Monitoring#
Overview#
Glances is a cross-platform monitoring tool that aggregates data from multiple subsystems (CPU, memory, disk, network, sensors) into a single dashboard. It supports CLI, web, and even mobile interfaces, making it ideal for both local and remote monitoring.
Installation#
-
Debian/Ubuntu:
sudo apt install glances -
Fedora/RHEL:
sudo dnf install glances -
Arch Linux:
sudo pacman -S glances
Basic Usage#
- CLI Mode: Launch with
glances. - Web Interface: Run
glances -wto start a web server, then accesshttp://<your-ip>:61208in a browser. - Mobile App: Use the Glances Mobile app to connect remotely.
Example CLI Output:
Glances 3.3.1.1 │ CPU [||||||||| 45.0%] │ Mem [||||||||||||||| 78.2%] │ Swap [| 5.0%]
Disk I/O: / 5.2G/20G (26%) │ Network: eth0 1.2M↓/890K↑
Key Features#
- Monitors CPU, memory, disk I/O, network, sensors, and even Docker containers.
- Alert system (high CPU/memory usage triggers color warnings).
- Export data to CSV, InfluxDB, or Prometheus for long-term analysis.
4. iostat: Disk I/O Performance Analysis#
Overview#
iostat (part of the sysstat package) focuses on disk and CPU I/O statistics. It helps identify bottlenecks by measuring read/write speeds, disk utilization, and queue lengths.
Installation#
iostat is included in the sysstat package:
-
Debian/Ubuntu:
sudo apt install sysstat -
Fedora/RHEL:
sudo dnf install sysstat -
Arch Linux:
sudo pacman -S sysstat
Basic Usage#
-
Basic Disk Stats:
iostat -
Extended Stats (Every 5 Seconds):
iostat -x 5Key metrics in
-xoutput:%util: Percentage of time the disk was busy (values >70% indicate saturation).r/s/w/s: Reads/writes per second.kB_read/s/kB_wrtn/s: Throughput in kilobytes per second.
Key Features#
- Focused on disk I/O performance (rotational HDDs and SSDs).
- Historical data collection (via
sar, anothersysstattool). - Helps diagnose slowdowns caused by storage bottlenecks.
5. nvtop: GPU Monitoring for NVIDIA/AMD#
Overview#
nvtop (NVIDIA Top) is a GPU-focused monitoring tool, similar to htop but for graphics cards. It supports NVIDIA GPUs (via nvidia-smi) and AMD GPUs (via rocm-smi), displaying memory usage, temperature, and processes using the GPU.
Installation#
-
Debian/Ubuntu:
sudo apt install nvtop -
Fedora/RHEL:
sudo dnf install nvtop -
Arch Linux:
sudo pacman -S nvtop
Basic Usage#
Launch with:
nvtop Interface:
- GPU utilization (graphs for memory, core, and power).
- List of processes using the GPU (e.g., games, CUDA tasks).
- Temperature and fan speed (if supported).
Key Features#
- Real-time GPU metrics for gaming, mining, or AI workloads.
- Supports multi-GPU setups.
- Lightweight and easy to interpret.
6. smartctl: Storage Health with S.M.A.R.T.#
Overview#
smartctl (part of smartmontools) interacts with the S.M.A.R.T. (Self-Monitoring, Analysis, and Reporting Technology) system built into most HDDs and SSDs. It detects early signs of disk failure (e.g., bad sectors) and predicts drive longevity.
Installation#
-
Debian/Ubuntu:
sudo apt install smartmontools -
Fedora/RHEL:
sudo dnf install smartmontools -
Arch Linux:
sudo pacman -S smartmontools
Basic Usage#
-
Check if S.M.A.R.T. is Enabled:
sudo smartctl -i /dev/sda # Replace /dev/sda with your driveLook for
SMART support is: Enabled. -
Run a Health Check:
sudo smartctl -H /dev/sdaOutput example:
SMART overall-health self-assessment test result: PASSED -
View Detailed Attributes:
sudo smartctl -a /dev/sdaCritical attributes to watch:
Reallocated_Sector_Ct: Number of bad sectors (should be 0).Temperature_Celsius: Drive temperature.
Key Features#
- Predicts disk failure before data loss occurs.
- Supports both HDDs and SSDs.
- Can run short/long self-tests to validate drive integrity.
7. Psensor: Graphical Hardware Monitoring#
Overview#
Psensor is a GUI tool that visualizes sensor data (temperatures, fan speeds) in real time. It’s ideal for users who prefer a graphical interface over the command line and can display data in the system tray.
Installation#
-
Debian/Ubuntu:
sudo apt install psensor -
Fedora/RHEL:
sudo dnf install psensor -
Arch Linux:
sudo pacman -S psensor
Basic Usage#
Launch Psensor from your application menu. Features include:
- Real-Time Graphs: CPU, GPU, and disk temperatures over time.
- System Tray Icons: Show current CPU temperature at a glance.
- Alerts: Configure notifications for high temperatures (e.g., "CPU > 80°C").
Key Features#
- User-friendly GUI with customizable graphs.
- System tray integration for quick monitoring.
- Supports all sensors detected by
lm-sensors.
8. collectl: Advanced System Data Logging#
Overview#
collectl is a lightweight tool for collecting and logging system data over time. It monitors CPU, memory, network, disk, and more, making it suitable for long-term performance analysis or troubleshooting intermittent issues.
Installation#
-
Debian/Ubuntu:
sudo apt install collectl -
Fedora/RHEL:
sudo dnf install collectl -
Arch Linux:
sudo pacman -S collectl
Basic Usage#
-
Live Monitoring (All Subsystems):
collectl -
Log to File (Every 10 Seconds):
collectl -s cmnd -oT -f /var/log/collectl.log --interval 10-s cmnd: Monitor CPU, memory, network, disk.-oT: Include timestamps.-f: Output to file.
-
Analyze Logs: Use
collectl -p /var/log/collectl.logto parse and display logged data.
Key Features#
- Low overhead (uses <1% CPU).
- Supports custom data collection intervals.
- Integrates with tools like
gnuplotfor visualization.
Conclusion#
Linux offers a rich ecosystem of hardware monitoring tools, from lightweight CLI utilities like lm-sensors to feature-packed GUI tools like Psensor. Whether you’re a system administrator tracking server health or a desktop user optimizing gaming performance, there’s a tool for every need:
- Start with
lm-sensorsfor low-level sensor data. - Use
htoporGlancesfor real-time resource monitoring. - Diagnose disk issues with
iostatandsmartctl. - Monitor GPUs with
nvtop. - Log long-term data with
collectl.
By combining these tools, you can proactively maintain your system’s health and performance.