High CPU Usage
Linux Linux
Severity: ModerateWhat Does This Error Mean?
High CPU usage on Linux means one or more processes are consuming most of the processor's capacity, leaving little for everything else. This causes slow response times, lag, and heat. The top or htop command shows you immediately which process is responsible. Common culprits include runaway background jobs, a software compilation process, a virus scanner, or a misbehaving application. Identifying the guilty process is the first step — then you can decide whether to kill it, adjust its priority, or fix the underlying cause.
Affected Models
- Ubuntu
- Debian
- Fedora
- Arch Linux
- Linux Mint
- CentOS
- Rocky Linux
Common Causes
- A runaway process — a program stuck in an infinite loop consuming 100% of a CPU core
- A package manager update or software compilation running in the background
- An antivirus or security scanner doing a scheduled full-system scan
- A system service like journald, updatedb, or locate building its database
- A cryptocurrency miner or malware installed without the user's knowledge
How to Fix It
-
Open a terminal and run: top — or if installed, run: htop (install with: sudo apt install htop on Debian/Ubuntu). Look at the top of the list — processes are sorted by CPU usage by default. Note the PID (process ID) and command name of the top consumer.
Press P in top to ensure sorting by CPU. Press Q to quit. htop has a more visual interface and is easier to read.
-
If you find an unknown or suspicious process, look it up. Run: ps aux | grep [process_name] to see more details, and: ls -la /proc/[PID]/exe to see the actual file path the process is running from.
Legitimate system processes run from /usr/bin, /usr/sbin, or /lib. A process running from /tmp, /var/tmp, or a hidden folder is suspicious.
-
To temporarily stop a runaway process without killing it permanently, lower its priority with nice and renice. Run: sudo renice 19 -p [PID] — this gives the process the lowest CPU scheduling priority, letting everything else run freely.
Priority values in Linux range from -20 (highest) to 19 (lowest). Setting a process to 19 means it only gets CPU time when nothing else needs it.
-
If the process is genuinely runaway and safe to terminate, kill it. Run: kill [PID] for a graceful shutdown request, or: kill -9 [PID] to force-terminate it immediately.
kill -9 forces the process to stop with no chance to clean up. Use it only if the regular kill command has no effect after 10-15 seconds.
-
If the high CPU is from updatedb or locate running a database update, it will finish on its own. To stop these from running at inconvenient times, edit their cron schedule. Run: sudo crontab -e and adjust or remove the updatedb entry.
updatedb scans the entire file system to build a search index. On large systems this can take considerable time and CPU. Scheduling it for off-hours (like 3 AM) is a good practice.
When to Call a Professional
If you find an unknown process consuming CPU that cannot be identified or stopped, run a malware scan. CryptoMiners are a real threat on Linux servers. On server systems, a security audit by a Linux administrator is recommended if suspicious processes are found.
Frequently Asked Questions
My CPU usage is always high but I cannot see an obvious cause in top. Why?
If no single process shows very high CPU but overall CPU usage is still high, many small processes may each be using a small amount. This is called CPU pressure and is different from a runaway single process. Run: sar -u 1 10 (from the sysstat package) to see CPU usage breakdown over time. Also check for I/O wait (wa column in top) — high I/O wait means the CPU is spending most of its time waiting for the disk, not actually processing.
What is a runaway process?
A runaway process is one that gets stuck in a programming error — usually an infinite loop — and never voluntarily gives up the CPU. Normally, programs share the CPU by taking turns. A runaway process takes its turn and never passes it to the next program. It will keep consuming 100% of one CPU core indefinitely until it is killed. This is a software bug, not a hardware problem.
How do I prevent high CPU from making my whole system unresponsive?
Install and configure cgroups or systemd resource control to limit how much CPU any single service can use. For desktop systems, you can also install cpulimit (sudo apt install cpulimit on Debian/Ubuntu) and use it to cap specific applications: cpulimit -p [PID] -l 50 limits the process to 50% CPU. For long-term prevention, consider enabling earlyoom (an out-of-memory handler) which can automatically kill runaway processes before they freeze the system.