How to Clear Buff/Cache in Linux

You can clear the buff/cache cache in a Linux system by using the following method:

  1. To utilize the sync command: the sync command is able to write the data in the cache to the disk, thus freeing up space in the buff/cache. Enter the following command:
sync
  1. You can clear buffer/cache memory by using the echo command to write a value to the /proc/sys/vm/drop_caches file. Enter the following command:
sudo sh -c "echo 3 > /proc/sys/vm/drop_caches"

The number 3 represents clearing page cache, directory cache, and inode cache.

  1. Rebooting the system: Rebooting the system can also clear the buff/cache memory. Enter the following command:
sudo reboot

It is important to note that clearing buff/cache memory may lead to a decrease in system performance, as the system will need to reload the cleared data. Therefore, it is recommended to only clear buff/cache memory when necessary.

bannerAds