How to clear cache on Linux?

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Hello, friends. Clearing the Linux cache can bring us certain advantages that we should take a look at. Today you will learn how to do it on Linux. Let’s go.

Is it necessary to clear the cache?

Occasionally, when we use a computer without too many resources or when we notice an abuse in the use of RAM, it is convenient to clear the cache of the entire system.

Remember that by default, Linux makes the cache grow until it uses all the available memory. This is not all bad, but it is true that each time it can trigger the consumption making the video playback, for example, is very slow.

So, as a possible corrective measure, you can clear the system cache

Clear the cache on Linux

The process is actually basic to do. One of the first things we have to do is to open a terminal.

Then, you will have to run the commands as root user to do this run

sudo -i

Or if the root user is active, you can access this other way

su

Then, simply run the following command

sync && echo 3 > /proc/sys/vm/drop_caches

Immediately, the cache will be removed, and you will be able to notice a change in the system monitor if you have it active.

Another way to clear the cache

Another way to do this, especially on Ubuntu-based systems, is with the systemd-resolve command. This command comes as standard on Ubuntu and is an easy solution to the problem.

So, all we will have to do is run

sudo systemd-resolve --flush-caches

This will quickly flush the system cache.

That same command can give statistics about the use of the cache

sudo systemd-resolve --statistics

Sample output

Clearing the Linux cache
Clearing the Linux cache

Conclusion

In this short but simple post, you learned how to remove the system cache and above all how to do it from Ubuntu.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook