How to clear cache on any distribution Linux?

Windows Articles

How to permanently delete files in Windows 10

Hello, how are you? As we use the computer, it fills up with files and information. Indeed, the user is used to...

How to improve your sleep with your Android device

Every day new apps are released for our Android device, focused on different aspects of our lives. It is a world full...

Install Python 3.9 on Ubuntu 20.04 / 18.04

Hi, folks. In this post, I will show you how to install Python 3.9 on Ubuntu 20.04 / 18.08

How to Install MinGW on Windows 10

Hello! We usually work with many applications in Windows 10. However, some applications are more delicate than others. For example, native applications....

How to install Apache Tomcat on Ubuntu 20.04 / Debian 10?

Even though Python is the most popular programming language actually, there is still confidence in Java. So you probably needed to make applications with...
angeloma
angeloma
Senior Writer and partner

Hello, friends. In this very short post, we will show you how to clear the cache in Linux. This tutorial, although it will be done in Ubuntu, will work in any distribution that has systemd.

Linux is an operating system that manages memory very well and that’s why the cache exists. Every time we open a file or directory they are temporarily stored in the main memory to make them accessible and speed up the system. However, there are situations in which it is required to clean the cache to free more space in it.

So it can be done from the terminal without any problem. Let’s see.

Clear cache on any Linux distribution

The first thing to know is that in Linux there are several types of cache.

On the one hand, there is the PageCache that refers to files and programs that are stored in RAM and do not need to be reloaded from the hard disk.

On the other hand, there is Dentry and inode cache which are the attributes of these files.

So let’s get to the point.

First, execute the free command with the -h argument so that you notice how the RAM is being used.

free -h

In my case the screen output gives the following data:

total used free shared buff/cache available
Mem: 3,7G 2,2G 145M 242M 1,3G 934M
Swap: 964M 11M 953M

As you can see my computer has little RAM and the cache takes a good part.

If you want to clean it up, just execute the following command:

sudo sysctl vm.drop_caches=3

This command will remove all the cache, but you can also just remove the PageCache, by running

sudo sysctl vm.drop_caches=1

Or just the inodes:

sudo sysctl vm.drop_caches=2

In any case, if you execute the free command again you will be able to notice the results.

free -h

So, congratulations, you completed the tutorial and you know how to clear cache on Linux.

Conclusion

Generally, you will probably never feel the need to go through this process, but it is good to know so that you can use it when necessary.

Finally, remember that cleaning the cache can slow down the system at first, but it can be used in specific cases.

So, share this post and join our Telegram channel and our Facebook page. Also, buy us a coffee 😉

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

How to permanently delete files in Windows 10

Hello, how are you? As we use the computer, it fills up with files and information. Indeed, the user is used to...

How to improve your sleep with your Android device

Every day new apps are released for our Android device, focused on different aspects of our lives. It is a world full...

Install Python 3.9 on Ubuntu 20.04 / 18.04

Hi, folks. In this post, I will show you how to install Python 3.9 on Ubuntu 20.04 / 18.08

How to Install MinGW on Windows 10

Hello! We usually work with many applications in Windows 10. However, some applications are more delicate than others. For example, native applications....

How to install Apache Tomcat on Ubuntu 20.04 / Debian 10?

Even though Python is the most popular programming language actually, there is still confidence in Java. So you probably needed to make applications with...
x