7 Easy Ways To Fix High CPU Usage In Linux

Due to High Cpu Usage in Linux, there are times when you frequently have to struggle with delayed or unresponsive programs.

high cpu usage linux

This occurs when the CPU in your Linux system is overloaded; as a result, subsequent requests cannot usually be processed, and the queued requests must wait until the CPU is free.

Use the proper instructions to determine the processes generally consuming the CPU in Linux if you want to know which ones are taxing it.

What is the CPU limit?

There are various levels at which a CPU limit can be set: it denotes a percentage cap on the database’s access to CPU resources.

A percentage cap on the host’s or LPAR’s available CPU resources for all of the function superclass’s subclasses is represented at this level. You can check the CPU limit using the iostat command and the mpstat command.

What causes high CPU usage In Linux?

The most common causes of High CPU usage are:

  1. Resource problem – High CPU utilization may be caused by system resources, including RAM, disc space, memory usage, Apache, etc. These can be solved by removing the cache.
  2. Code error – An application problem may result in memory leaks and other issues.
  3. System configuration – Utilization problems may result from default settings or other configuration errors. 

How do you troubleshoot CPU performance?

Here you will find out how to troubleshoot High Cpu Usage in Linux.

  • Reboot. Start by saving your work and restarting your computer.
  • Finished or new processes. (CTRL+SHIFT+ESCAP) Launch the Task Manager.
Launch the Task Manager.
  • Upgrade the drivers
Upgrade the drivers
  • Verify for malware.
  • Choose Power Options.
Choose Power Options.
  • Locate Specific Advice Online.
  • Reinstall Windows.

How do I limit CPU usage?

Follow this metric to limit CPU usage:

  • Power control of the processor. Access the Control Panel.
  • Choose hardware and sound.
  • Then select Power options.
select Power options.
  • Edit the plan’s settings.
Edit the plan's settings.
  • Modify the power settings.
  • Reduce the processor state to the maximum, 80%, or whatever you choose.
Reduce the processor state to the maximum, 80%, or whatever you choose.

How to Fix High CPU Usage in Linux OS?

There are various ways to fix high CPU utilization in Linux, like using the ps command and the sar command, but we would like to recommend you go step by step.

  1. Find the Culprit
  2. Update Everything
  3. Remove and Reinstall the App using Ubuntu
  4. Renice or Kill the App
  5. Use Alternative App
  6. Revert to the Previous Version
  7. Fix Core Apps Causing High CPU Usage

1. Find the Culprit

Even the fastest processors can crash due to a problematic app. To locate the offending application, use the top in the terminal or the System Monitor app.

Open a terminal, enter the top, and then close it; if you want to cancel it, press ctrl-c or discard it.

Open a terminal

All processes are default ranked from most CPU-hungry to least CPU-hungry based on their CPU load average.

You’ve identified the offending program if it consistently occupies one of the top five positions with a CPU consumption rate much greater than the others.

2. Update Everything

The app may need to be updated if the issue keeps happening, no matter how many times you run it.

Enter the following command in your terminal: 

sudo apt update && sudo apt -y upgrade

Update Everything

Run the troublesome application once again after that.

3. Remove and Reinstall the App using Ubuntu

If the issue still needs to be resolved, there’s a potential that it will come back because of a misconfigured parameter in the ubuntu application. It can be helpful to reset it to its initial state.

Before you remove the troublesome program, make a backup of your configuration in case it wasn’t the root of the issue, and you need to restore it later. Use this cmd:

sudo apt purge APP_NAME

sudo apt autoremove

Enter the command in your terminal:

Reinstall the app using the following command: 

sudo apt update

sudo apt install APP_NAME

sudo apt update

The app will be restored to its initial state after this.

4. Renice or Kill the App

Support for both renice and kill is included at the top. A nice app can be used to interrupt a process forcibly or to adjust its priority.

Support for both renice and kill is included at the top.

The amount of CPU resources the nice app is permitted to use compared to other active processes is referred to as its good priority. Nice takes values between +19 and -20. The stress decreases as the number increases.

Press R on top and type the PID of the problematic app. If changing it to a “+5” value doesn’t work, try again with “+10,” “+15,” and finally “+19,” which is the lowest priority.

Press R on top and type the PID of the problematic app.

Please stop using the nice app as soon as it stops responding. The app will be deleted if you press k while on top, enter the PID, and press Enter.

5. Use Alternative App

Linux has the benefit of having a wide variety of applications that can do the same function. You can and should substitute an alternate software if one is taking a lot of CPU resources.

LibreOffice Writer, for instance, can be a problematic piece of software because it requires numerous dependencies to function effectively.

Abiword is a fantastic substitute for this application. Run the following command in the command line to set it up in Ubuntu:

sudo apt install AbiWord

LibreOffice Writer

6. Revert to the Previous Version

Reverting to the earlier version is an option if upgrading the program didn’t fix the issue. To use the program until the developer fixes the flaws, try downgrading and utilizing an earlier version.

Check out the available versions by launching your terminal and performing the cmd: to downgrade your program before doing so:

sudo apt policy APP_NAME

The version you are using right now will have three asterisks next to it. Keep an eye out for the alternative variations:

We advise you to purge the current version to eliminate any configuration-related issues before downgrading.

Install the previous version by using this in the command line:

sudo apt install APP_NAME=VERSION

Revert to the Previous Version

7. Fix Core Apps Causing High CPU Usage

What happens if a core app like systemd or Xorg uses up all your CPU power and memory usage?

Try turning off extra hardware on your computers, like joysticks and printers, to disable systemd.

Suppose you’re using Ubuntu or another equal distribution, and the device is a joystick, mouse, or keyboard. In that case, you may see all connected devices by typing xinput in your terminal—use: to make one of them inoperative.

xinput –disable DEVICE_id

Replace disable with enable in the command above to re-enable the device.

The answer is a little trickier for other devices. To see all the additional drivers your Linux kernel loads as modules, type lsmod in your terminal and press Enter. Once you’ve located the one for the problematic device and written down its name, type the following:

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

An unloadable module blacklist is contained in the document you just opened. It most likely has a few entries in it already. The exact syntax should be used at the file’s end to add your module to this list. Your submission should resemble the following:

blacklist MODULE_NAME

After rebooting and saving the file, everything may function adequately.

Try turning off the compositor in your Window Manager for Xorg. Even though this is the official policy, there are times when the GPU handles CPU-related activities instead. Sometimes, activating compositing support also enables a lot of labor-intensive effects.

Occasionally, high CPU utilization can also be brought on by the GPU drivers. Specific AMD or Nvidia driver versions and Xorg need to get along.

Upgrading or downgrading to a different version is the answer. Alternatively, try open-source drivers for your GPU.

However, they have different precise feature sets and might need more capabilities.