Clear Cache on Linux: Step-by-Step Guide
To clear the cache on a Linux system, you can follow these steps:
- Open the terminal window.
- Logging in with root privileges allows you to use the sudo command or switch to the root account.
- 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.
- 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.
- 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.
- 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.