Skip to main content

At first, I attempted

echo 1 > /proc/sys/vm/drop_caches

Response

-bash: /proc/sys/vm/drop_caches: Permission denied

Adding sudo in front of the command was met with the same result.  What about if I execute the shell as root

sudo sh -c 'echo 1 > /proc/sys/vm/drop_caches'

Success.  Caches cleared.

 

Different types of clearing cache

 

Clear PageCache only

sudo sh -c 'echo 1 > /proc/sys/vm/drop_caches'

Clear dentries and inodes

sudo sh -c 'echo 2 > /proc/sys/vm/drop_caches'

Clear pagecache, dentries, and inodes

sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'

 

 

Related articles

Andrew Fletcher18 Mar 2024
Resolving CVE-2022-48624 less issue
To resolve the CVE-2022-48624 vulnerability on Ubuntu using Nginx, it's crucial to understand that the issue lies within the "less" package, not Nginx itself. The vulnerability affects "less" before version 606, where close_altfile in filename.c in less omits shell_quote calls for LESSCLOSE,...
Andrew Fletcher06 Mar 2024
Terminal command to find and replace
In many terminal text editors, you use find command as reference in Terminal commands - find.  How about find and replace.  This action depends on the specific text editor you're using in the terminal.  Here are a few common terminal text editors and how you can find and replace...