Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am currently having some issues with the cache. It is a little too much right now so I wanted to clear it. I googled and found this little command: sync && echo 3 > /proc/sys/vm/drop_caches.
I am logged in as root over SSH (not using sudo). These are the attempts I made:

root@server: ~ # ll /proc/sys/vm/drop_caches
-rw-r--r-- 1 root root 0 15. Jan 20:21 /proc/sys/vm/drop_caches

root@server: ~ # echo 3 > /proc/sys/vm/drop_caches
-bash: /proc/sys/vm/drop_caches: Permission denied

root@server: ~ # sudo su -c "echo 3 > /proc/sys/vm/drop_caches"
bash: /proc/sys/vm/drop_caches: Permission denied

root@server: ~ # echo 3 | sudo tee /proc/sys/vm/drop_caches
tee: /proc/sys/vm/drop_caches: Permission denied

It is a remote machine running Debian. As far as I know there are some vCores in this machine and it uses Virtuozzo for the virtualization.
I really just want to clear the cache (So I can only access it using SSH).
I also tried registering this as a cronjob. But it simply fails too!

share|improve this question
Are you running this as root or are you using sudo? – terdon Jan 15 '14 at 19:52
I am running this as root. But sudo also fails. – BrainStone Jan 15 '14 at 19:53
Does not work either. Already tried it. Same error message. – BrainStone Jan 15 '14 at 19:55
See the slm's A on this question, it might help. – Risto Salminen Jan 15 '14 at 19:58
@terdon : Whoops. Retracted. – goldilocks Jan 15 '14 at 20:00
up vote 15 down vote accepted

I am logged in as root over SSH...It is a remote machine running Debian.

Is it actually a remote machine, or a just a remote system? If this is a VPS slice somewhere, (at least some forms of) OS virtualization (e.g. openVZ) won't permit this from within the container. You don't run the machine, you just run your slice.

share|improve this answer
There is like no way??? – BrainStone Jan 15 '14 at 20:09
Probably not, since there wouldn't be much point in not permitting it if there were alternate methods that worked. – goldilocks Jan 15 '14 at 20:11
@BrainStone - I use OpenVZ, it's not possible! – slm Jan 15 '14 at 21:42

This is normal behavior under OS-level virtualization. This can only be executed by someone with root access to the hardware node.

With for example OpenVZ, you don't get your own kernel instance and as such, are restricted from performing commands like this.

All share the same page cache, so to drop caches of only your instance, the kernel must check if the page belongs to you and if the other instances aren't using this page too.

With another virtualization technique like KVM or Xen this might be working.

share|improve this answer
So I could/should/must contact my hoster to clear the cache for me? And how do I find out what "virtualisation technique" my system is on? – BrainStone Jan 15 '14 at 20:15
Yes, you may not come around this... – chaos Jan 15 '14 at 20:18
I am not shure if this is right. I am running some vm's at aws and Xen and i am able to drop_caches. – user55518 Jan 15 '14 at 20:51
The difference is between OS virtualization (OpenVZ, LXC) and platform virtualization (QEMU, Xen), both of which have advantages and disavantages vs. the other. – goldilocks Jan 15 '14 at 21:52
@bersch Xen uses an own kernel for VMs. OpenVZ does not. You can think of OpenVZ like a better "chroot". – Nils Jan 20 '14 at 11:49

sudo has to cover whole redirection in order it can be completely executed under root:

$ sudo sh -c “/usr/bin/echo 3 > /proc/sys/vm/drop_caches”
share|improve this answer
this actually worked for me (with the right binary location for echo) – orm Nov 5 '14 at 19:59
in OpenVZ not work – shilovk Mar 3 '15 at 16:03
alternatively, you could use tee instead: echo 3 | sudo tee /proc/sys/vm/drop_caches – mchid Dec 23 '15 at 0:09
Working in an Azure VM. Thanks! – lordcheeto Feb 9 at 6:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.