Whether you have built a new desktop workstation, provisioned an Ubuntu server in the cloud, or replaced thermal paste on an overheating laptop, verifying hardware stability under intense processing loads is crucial. An unstable system that crashes during production workloads, kernel compilation, or long database queries can result in data corruption, unexpected reboots, and prolonged downtime.
While the older stress tool provided basic workload generation, modern Linux systems rely on stress-ng (Stress Next Generation). Maintained by the Ubuntu kernel team, stress-ng includes over 300 specialised stressors capable of testing CPU cores, vector registers, cache hierarchies, virtual memory subsystems, and disk I/O controllers. In this guide, you will learn how to install, configure, and execute stress tests in Ubuntu using stress-ng.
Why Use stress-ng for Linux Stability Testing?
Stress testing your hardware configuration provides vital diagnostic feedback:
- Evaluates cooling and thermal throttling: Sustained multicore workloads reveal whether CPU fans, liquid coolers, and case ventilation maintain temperatures within safe operating limits.
- Identifies memory bit flips and hardware degradation: Pushing RAM and cache hierarchies uncovers latent silicon faults before they corrupt production files.
- Validates power supply stability: Sudden wattage spikes generated by synthetic load testing ensure your power delivery units (PSU) and VRMs do not brown out under maximum draw.
Step 1: Installing stress-ng on Ubuntu
The stress-ng utility is included in the standard Ubuntu repositories. Open your terminal and install it along with a temperature monitoring tool:
sudo apt update
sudo apt install stress-ng lm-sensors -y
If you have not configured sensor monitoring previously, run sudo sensors-detect --auto to detect your motherboard and CPU temperature sensors.
Step 2: Running a Basic CPU Stress Test
To run a standard CPU stress test across all available CPU cores for a fixed duration, use the --cpu and --timeout options:
stress-ng --cpu 0 --timeout 60s --metrics-brief
In this command:
--cpu 0automatically spawns one stressor worker per detected online CPU core (e.g. 8 workers on an 8-core/16-thread processor).--timeout 60shalts the test automatically after 60 seconds. You can specify minutes (m) or hours (h), such as10mfor a thorough 10-minute burn-in.--metrics-briefprints an informative summary of bogo operations per second upon completion.
Step 3: Stress Testing Virtual Memory (RAM)
Memory instability often leads to kernel panics or segmentation faults. To stress test your physical RAM and swap space, use the --vm stressor:
stress-ng --vm 4 --vm-bytes 80% --timeout 5m --metrics-brief
This command spawns 4 memory workers that collectively allocate and continually write to 80% of your total available system memory for 5 minutes, exercising memory controllers and paging algorithms.
Step 4: Monitoring System Temperatures During Stress Testing
While stress-ng is running in one terminal window, open a secondary terminal pane or window and monitor live hardware metrics in real time:
watch -n 1 sensors
Alternatively, monitor real-time CPU clock speeds, utilisation, and package temperatures using htop or s-tui (Stress Terminal UI):
sudo apt install s-tui -y
s-tui
If CPU temperatures exceed 90°C–95°C and thermal throttling kicks in, stop the test immediately with Ctrl + C to inspect your cooler mounting and thermal compound application.
Step 5: Running a Combined Matrix and Thermal Torture Test
To execute a comprehensive stress test combining CPU integer calculations, floating-point matrix multiplications, and memory bandwidth:
stress-ng --cpu 0 --cpu-method matrixprod --vm 2 --vm-bytes 4G --timeout 15m --metrics-brief
If your Ubuntu workstation completes a 15-minute test without kernel panics, system freezes, or automatic shutdowns, your hardware cooling and silicon stability are verified for demanding production tasks.