The problem with:
sudo echo 1 > /proc/sys/vm/drop_caches
is that the redirect happens in the initial shell - i.e. under your own account - before the "sudo echo 1" happens, which isn't the part that really needs root access. You need to get the opening of drop_caches by ">" to be inside of the sudo. One lazy way (lazy because it clones the 3 back to stdout, which you don't actually need) is:
echo 3 | sudo tee /proc/sys/vm/drop_caches
The options to write into drop_caches are:
- Free pagecache
- Free dentries and inodes
- Free pagecache, dentries, and inodes.
And you should sync first, so all in all:
sync ; echo 3 | sudo tee /proc/sys/vm/drop_caches
or if you don't like the spurious "3" on stdout:
sudo sh -c 'sync ; echo 3 >/prod/sys/vm/drop_caches'