There are users who opt for this format because they reject Windows, for whatever reason. It may be because of the cost it has, because of its high consumption of resources, because of telemetry, because of its UWP applications, etc. Be that as it may, the truth is that the distros that we can use at the moment are more than interesting options. Also, there are many users who opt for this alternative to give a second life to their old computers.
And it is that in general terms many Linux distributions have a much lower consumption how many resources than the proposal of Microsoft. But that does not mean that we cannot have some problems related to this very issue. That is, it may be the case that we install viruses on our computer and on certain occasions we do not have a high CPU consumption, for instance.
Reasons why Linux is consuming a lot of resources
Let’s not forget that this type of software also uses the computer’s RAM, processor and GPU to function. As we mentioned before, in most cases this consumption will be lower than the average in Windows, but we cannot translate that as null. In fact, on some occasions we are going to encounter certain problems related to this issue.
Keep in mind that we are also talking about a highly complex operating system that also most of the time has a multitude of installed apps. Therefore, this high consumption to which we refer can be given for multiple reasons. It may be the case that some of the installed programs have a problem. In addition, the operating system itself can at certain times start to perform maintenance tasks in the background, which will affect the rest of the PC.
Although it is rarer, it can also be the case that our computer has been infected by some type of malicious code. Explore that at specific times the use of the CPU is much higher than normal. Whatever your case, below we are going to try to help you through some solutions that will surely be useful when the time comes. Thus, in the event that your pc crashes or the CPU fan is speeding up, let’s see how to fix it.
Solutions for high CPU consumption in Linux
The resources of a computer are not unlimited, no matter how modern it is, so we must always have some control over all of it. In the event that we notice jumps, crashes, or some malfunction in certain applications, we should investigate it. In many cases, all this is due to a high consumption of processor or CPU by the own OS or any of its applications. This can lead to a complete PC crash, PC overheating, etc. Therefore, the best we can do is try to solve it as soon as possible.
Locate the harmful program or process
It may be the case that a certain application does not behave as it should, which translates into a high consumption of resources. To locate it, one of the possible solutions that we can use the system Terminal. We access it through the key combination Ctrl + Alt + T, for instance.
Once we are in Terminal, we will have to use the following command that we type here:
By default, all program processes are ordered according to their CPU usage, placing those that consume the most at the top. Therefore, if we see that a certain application spends an excessive amount of this component, we already know who is to blame for the evil Linux operation.
Terminate the process that is consuming too much CPU
Once we have located the item that is doing excessive consumption, the best we can do is end it in the system. This is something that we can also carry out from the Terminal which we discussed in the previous step. Therefore, in order to have a view of the process that we want to eliminate, we only have to write down or memorize its PID. Next, we click on the R key and we introduce said the PID of the problematic application and change its value to +5 +10, +15 or +19.
If the application itself does not respond, we must end it immediately. Thus, we press the K key and re-enter the PID so that the program disappears.
Update all installed programs
This problem, which in this case can be caused by an old version of a certain application. Therefore, it is recommended that we update all of them at once and thus solve the trouble root. In addition, this same movement will help us to have the most recent versions of the programs that we have and we will patch the latest security holes.
For this that we tell you we have to reopen a Terminal window, in the same way that we commented previously. Next, in it we will have to type the following command:
sudo apt update && sudo apt -y upgrade
After this we should put the applications that were before running again to see if the problem has already been solved.
Remove and reinstall the problematic application
We already showed you before the way to locate the process or application which is consuming too much CPU on Linux. We tell you this because the situation can also occur in which the only solution is to delete that program and reinstall it again so that it behaves in a normal way. The reason for this may be given by some erroneous parameter in the program’s configuration that makes it consume more processor. At this point, restoring it to its original state can help. Here the first thing we recommend is to make a backup copy of the configuration and thus be able to restore it in the future. After that and again from the terminal, delete the problematic application with this command:
sudo apt purge NOMBRE_APLICACION
Once it has been completely removed from the operating system, we only have to reinstall it in it through this command:
sudo apt install NOMBRE_APLICACION
This will restore the application to its original state and therefore the problem we are facing in this case should have been solved.
Install an older version of CPU consuming software
If updating the problem application has not resolved consumption, you can revert to its previous version. By taking a step back from the version and using an older version, we save time until the developer has corrected the possible mistakes. To achieve this, we first look at the versions available from Terminal and with the command:
sudo apt policy NOMBRE_APLICACION
The version currently installed will be seen with three asterisks next to it and we can write down the other versions available. We install the previous version, with the following command:
sudo apt install NOMBRE_APLICACION=VERSION
Troubleshoot system applications
But high CPU usage is not always going to be the fault of third-party applications, as system elements like systemd or Xorg they may also have a lot to do with it. In the event that we see that the process systemd is the culprit of the problem, disables non-essential functions and unplug the UB secondary devices and the printer. To do this, we return to Terminal and use the command:
xinput --disable ID_DISPOSITIVO
To re-enable it, we change Disable to Enable in the command that we have just shown you.
Change Linux Kernel
First of all, we will tell you that it is a bit strange that the Linux kernel be the reason for high CPU utilization. But there have been cases, so, for example, to install the popular Liquorix Kernel in Ubuntu, from Terminal we write the command:
sudo add-apt-repository ppa:damentz/liquorix && sudo apt-get update
This will add the repository to the Ubuntu sources, so to bring it to our team we use the following:
sudo apt-get install linux-image-liquorix-amd64 linux-headers-liquorix-amd64
Now we only have to restart to enable the new Kernel and the CPU usage will return to normal levels.