Clear Cache on Linux: Step-by-Step Guide

To clear the cache on a Linux system, you can follow these steps:

  1. Open the terminal window.
  2. Logging in with root privileges allows you to use the sudo command or switch to the root account.
  3. Enter the command to clear the page cache:
sync; echo 1 > /proc/sys/vm/drop_caches

This command will perform a data synchronization operation and then write the number 1 to the /proc/sys/vm/drop_caches file, which will clear the page cache.

  1. Enter the command to clear directory entries and inode caches:
sync; echo 2 > /proc/sys/vm/drop_caches

This command will also sync data operations and then write 2 to the /proc/sys/vm/drop_caches file, which will clear the directory entry and inode caches.

  1. Input the following command to clear the page cache, directory entries, and inode cache:
sync; echo 3 > /proc/sys/vm/drop_caches

This command will also perform a data synchronization operation and then write 3 to the /proc/sys/vm/drop_caches file, which will flush the page cache, directory entries, and inode cache.

  1. at no cost

Please note that clearing the cache may result in a temporary decrease in system performance as the cache will need to be reloaded. Additionally, only users with root privileges can execute these commands.

bannerAds