How to Fix High CPU Usage in Linux

Fix High Cpu Usage Linux 00 Featured Image

Is your PC freezing? Or have you started hearing loud CPU fan noise coming from your computer? There are many reasons for high CPU utilization in Linux, but the most common is a misbehaving app. Read on to learn how you can fix high CPU usage in Linux.

Also read: How to Undervolt Your CPU With Throttlestop in Windows

1. Find the Culprit

A misbehaving app can bring even the fastest processors to their knees. You can use the System Monitor app or top in the Terminal to find the problematic application.

Open your terminal, type top, and press Enter.

Fix High Cpu Usage Linux 01 Top Program Sample

By default, all processes are sorted according to their CPU utilization, with the most CPU-hungry ones at the top. If an app is always in one of the top five slots with a CPU utilization rate significantly higher than the rest, you’ve found the culprit.

2. Renice or Kill the App

Top includes support for both renice and kill. You can use these tools to change the priority of any process or forcefully stop it.

Fix High Cpu Usage Linux 02 Renice Command

An app’s nice priority refers to the amount of CPU resources it’s allowed to use compared to the other running processes. Nice accepts values from +19 to -20. The higher the number, the lower the priority.

In top, press r and enter the problematic app’s PID. Try changing it to a “+5” value, and if that doesn’t help, retry with “+10,” “+15,” and finally the lowest possible priority, “+19.”

Fix High Cpu Usage Linux 03 Kill Command

If the app is unresponsive, you should stop it immediately. Press k while in top, enter the PID, press Enter, and the app will be gone.

Also read: How to Cool Down a High CPU Temperature

3. Update Everything

If the problem persists every time you run the app, updating it may fix the issue.

In your terminal, enter:

sudo apt update && sudo apt -y upgrade
Fix High Cpu Usage Linux 04 Sudo Apt Upgrade

After that, try running the problematic application again.

4. Remove and Reinstall the App

If the problem isn’t fixed, there’s a slight chance it appears because of a wrong parameter in the program’s configuration. Resetting it to its original state may help.

First, back up your configuration in case it wasn’t the cause of the problem and you need to restore it later, then purge the problematic app:

sudo apt purge APP_NAME
sudo apt autoremove
Fix High Cpu Usage Linux 05 Apt Purge Autoremove

Reinstall the app:

sudo apt update
sudo apt install APP_NAME
Fix High Cpu Usage Linux 06 Apt Install

This will reset the app to its original state.

Also read: 7 Best Apps to View Disk Usage in Linux

5. Revert to the Previous Version

If upgrading the app didn’t solve the problem, you can revert to the previous version instead. Try downgrading and using an older version – at least until the developer has fixed the bugs in the app.

To downgrade your app, first check out the available versions by running your terminal and issuing:

sudo apt policy APP_NAME

Your currently-installed version will have three asterisks next to it. Take note of the other available versions.

Before downgrading, we suggest you purge the existing version to eliminate any configuration-related problems.

Install the older version with:

sudo apt install APP_NAME=VERSION
Fix High Cpu Usage Linux 07 Apt Policy Version

6. Use Alternative App

The good thing about Linux is that there are many apps that can do the same thing. If one app is causing high CPU usage, you can and should replace it with an alternative.

For example, LibreOffice Writer can be a demanding piece of software, as it relies on many dependencies to run properly. One great alternative to this application is Abiword. To install it in Ubuntu, run the following command:

sudo apt install abiword
Fix High Cpu Usage Linux 08 Alternative Program Abiword

Also read: How to Create a .Desktop File for Your Application in Linux

7. Optimize Your System’s Power Settings

Another simple way to fix high CPU usage in Linux is to make sure that your machine can fully utilize its system resources. For the most part, a modern laptop will cap the maximum CPU frequency to conserve its battery, resulting in a slower laptop that constantly peaks in CPU load.

The quickest way to optimize your machine’s power settings is in your system settings menu. To do this in Ubuntu, press Win and type “settings.”

Fix High Cpu Usage Linux 09 Settings Search

Select the “Power” section from the window’s left side bar.

Fix High Cpu Usage Linux 10 Highlight Power Section

Select the “Balanced” option under the “Power Mode” category to allow the system to automatically allocate CPU resources whenever you need them.

Fix High Cpu Usage Linux 11 Power Mode Setting

Reboot your system to ensure that Ubuntu will apply your new settings correctly.

8. Install a Lightweight Desktop Environment

Aside from installing alternative applications and optimizing settings, you can also fix high CPU usage in Linux by installing a better desktop environment. One of the lightest environments for Linux is LXQt.

Fix High Cpu Usage Linux 12 Lxqt Desktop

Unlike GNOME and KDE, the developers of LXQt are dedicated to creating a complete desktop that can run on as few resources as possible. To install LXQt in Ubuntu, run the following command:

sudo apt install lxqt

Log out of your current session and select the gear icon on your login screen to display all of the available desktop environments in your system. Select “LXQt” and log in to your account.

Fix High Cpu Usage Linux 13 Lxqt Login Screen

Also read: 12 of the Best Linux Distros in 2022

9. Fix Core Apps Causing High CPU Usage

What happens if what’s eating up your CPU is a core app, like systemd or Xorg?

For systemd, try disabling non-essential features and secondary devices on your computer, such as joypads and printers.

If the device is a joypad, mouse, or keyboard, and you’re running Ubuntu or a compatible distribution, type xinput in your terminal to see all of the connected devices. To disable one of them, use:

xinput --disable DEVICE_ID
Fix High Cpu Usage Linux 14 Xinput Sample

To reenable the device, swap disable with enable in the above command.

For other devices, the solution is somewhat more complicated. First, you’ll have to enter lsmod in your terminal and press Enter to see all of the extra drivers your Linux kernel loads as modules. Find the one for the offending device and note down its name, then enter the following:

sudo nano /etc/modprobe.d/blacklist.conf

The document you just opened is a blacklist of modules that shouldn’t load during boot. It will probably already be populated with some entries. Move to the end of the file and follow the same syntax to add your module to this list. Your entry should look like:

blacklist MODULE_NAME

Save the file, reboot, and hopefully, everything will work okay now.

For Xorg, try disabling your Window Manager’s compositor. Although officially the compositor offloads CPU-related tasks to the GPU, that’s not always the case. Sometimes, by enabling compositing support, you’re also enabling many demanding effects.

Sometimes the GPU’s drivers can cause high CPU usage, too. Xorg doesn’t really get along with specific versions of Nvidia’s or AMD’s drivers. The solution is upgrading or downgrading to a different version. Alternatively, you can try open-source versions of your GPU’s drivers. Still, those don’t share the exact feature set and may lack some functionality.

10. Swap Your Kernel

It’s rare for the Linux kernel to be the reason for high CPU utilization. Still, if you’ve reached this point with no solution in sight, you won’t lose anything trying a different one.

As stated on its official site, to install the popular Liquorix kernel in Ubuntu, visit your terminal and type:

sudo add-apt-repository ppa:damentz/liquorix && sudo apt-get update
Fix High Cpu Usage Linux 15 Liquorix Repo Install

This will add its repository to Ubuntu’s sources. To bring the kernel itself onboard, use:

sudo apt-get install linux-image-liquorix-amd64 linux-headers-liquorix-amd64

Reboot to enable your new kernel, and, hopefully, your CPU utilization will be back to normal levels.

Also read: 5 Useful Tips When Compiling Your Own Linux Kernel

Frequently Asked Questions

I did a renice, but the app is still using a lot of CPU. Is it possible to lower it without killing the app?

Yes! One way to fix high CPU usage in Linux is to temporarily suspend its execution. Unlike doing a renice, suspending will immediately release the resources the offending program is currently using.

To do this, run kill -STOP followed by the PID of your program. Once you have the resources to run your program, resume by running kill -CONT.

Is it possible to set my system's power consumption to "High Performance" in Linux?

Yes! However, you need to edit your CPU’s frequency scaling policy by running the following command: echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor. This will force the system to use a more aggressive mode when utilizing its CPU, but on a laptop, it may significantly reduce its battery life. Easily go back to a more conservative mode by using echo powersave | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor.

Is it possible to reinstall my graphics drivers in Ubuntu Wayland?

Sadly, no. By default, the Wayland display server only uses the built-in kernel drivers for your graphics card, so it is not possible to tweak your graphics drivers without configuring and recompiling your own kernel.

Image credit: Unsplash. All alterations and screenshots by Ramces Red.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Ramces Red
Ramces Red - Staff Writer

Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.