“echo 3 > /proc/sys/vm/drop_caches” - Permission denied as root











up vote
18
down vote

favorite
3












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
3


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




















  • 1




    Are you running this as root or are you using sudo?
    – terdon
    Jan 15 '14 at 19:52






  • 2




    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
18
down vote

favorite
3












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
3


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




















  • 1




    Are you running this as root or are you using sudo?
    – terdon
    Jan 15 '14 at 19:52






  • 2




    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
18
down vote

favorite
3









up vote
18
down vote

favorite
3






3





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
3


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















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
3


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!







linux permissions virtualization proc openvz






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 30 '14 at 18:36









Tshepang

25.6k71182262




25.6k71182262










asked Jan 15 '14 at 19:42









BrainStone

1,14371941




1,14371941








  • 1




    Are you running this as root or are you using sudo?
    – terdon
    Jan 15 '14 at 19:52






  • 2




    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
















  • 1




    Are you running this as root or are you using sudo?
    – terdon
    Jan 15 '14 at 19:52






  • 2




    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










1




1




Are you running this as root or are you using sudo?
– terdon
Jan 15 '14 at 19:52




Are you running this as root or are you using sudo?
– terdon
Jan 15 '14 at 19:52




2




2




I am running this as root. But sudo also fails.
– BrainStone
Jan 15 '14 at 19:53




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






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




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






@terdon : Whoops. Retracted.
– goldilocks
Jan 15 '14 at 20:00












6 Answers
6






active

oldest

votes

















up vote
21
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



















  • 1




    There is like no way???
    – BrainStone
    Jan 15 '14 at 20:09






  • 1




    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






  • 2




    @BrainStone - I use OpenVZ, it's not possible!
    – slm
    Jan 15 '14 at 21:42


















up vote
23
down vote













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



















  • 5




    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






  • 1




    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 '16 at 6:52






  • 1




    @mchid, consider adding your comment as an answer. It also worked for me on Azure VM.
    – Erik Shilts
    Jan 26 '17 at 22:04


















up vote
11
down vote













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



















  • 1




    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






  • 2




    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








  • 1




    @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


















up vote
7
down vote













You can use echo piped to sudo tee to allow the proper permission needed when you need to echo as root.



echo 3 | sudo tee /proc/sys/vm/drop_caches


Use tee --help to list more options.






share|improve this answer




























    up vote
    0
    down vote













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



    This command work for me without /usr/bin/echo in mchid answer. It was giving error sh: 1: /usr/bin/echo: not found . So used only 'echo'






    share|improve this answer




























      up vote
      0
      down vote













      I had the same problem when I tried to use sudo like this:
      sudo echo 1 > /proc/sys/vm/overcommit_memory



      My solution was to temporarily switch to root. Obiously, that permission has to be enabled on your system:



      1. "sudo su -"  #temporarily switch to root user
      2. echo 1 > /proc/sys/vm/overcommit_memory
      3. exit # Exit as root.





      share|improve this answer





















        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "106"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        convertImagesToLinks: false,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f109496%2fecho-3-proc-sys-vm-drop-caches-permission-denied-as-root%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        6 Answers
        6






        active

        oldest

        votes








        6 Answers
        6






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        21
        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



















        • 1




          There is like no way???
          – BrainStone
          Jan 15 '14 at 20:09






        • 1




          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






        • 2




          @BrainStone - I use OpenVZ, it's not possible!
          – slm
          Jan 15 '14 at 21:42















        up vote
        21
        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



















        • 1




          There is like no way???
          – BrainStone
          Jan 15 '14 at 20:09






        • 1




          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






        • 2




          @BrainStone - I use OpenVZ, it's not possible!
          – slm
          Jan 15 '14 at 21:42













        up vote
        21
        down vote



        accepted







        up vote
        21
        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















        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














        share|improve this answer



        share|improve this answer








        edited Jan 15 '14 at 20:12

























        answered Jan 15 '14 at 20:06









        goldilocks

        61.3k13150205




        61.3k13150205








        • 1




          There is like no way???
          – BrainStone
          Jan 15 '14 at 20:09






        • 1




          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






        • 2




          @BrainStone - I use OpenVZ, it's not possible!
          – slm
          Jan 15 '14 at 21:42














        • 1




          There is like no way???
          – BrainStone
          Jan 15 '14 at 20:09






        • 1




          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






        • 2




          @BrainStone - I use OpenVZ, it's not possible!
          – slm
          Jan 15 '14 at 21:42








        1




        1




        There is like no way???
        – BrainStone
        Jan 15 '14 at 20:09




        There is like no way???
        – BrainStone
        Jan 15 '14 at 20:09




        1




        1




        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




        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




        2




        2




        @BrainStone - I use OpenVZ, it's not possible!
        – slm
        Jan 15 '14 at 21:42




        @BrainStone - I use OpenVZ, it's not possible!
        – slm
        Jan 15 '14 at 21:42












        up vote
        23
        down vote













        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



















        • 5




          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






        • 1




          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 '16 at 6:52






        • 1




          @mchid, consider adding your comment as an answer. It also worked for me on Azure VM.
          – Erik Shilts
          Jan 26 '17 at 22:04















        up vote
        23
        down vote













        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



















        • 5




          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






        • 1




          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 '16 at 6:52






        • 1




          @mchid, consider adding your comment as an answer. It also worked for me on Azure VM.
          – Erik Shilts
          Jan 26 '17 at 22:04













        up vote
        23
        down vote










        up vote
        23
        down vote









        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














        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














        share|improve this answer



        share|improve this answer








        edited Sep 14 '14 at 6:09

























        answered Aug 5 '14 at 6:50









        rasty.g

        35326




        35326








        • 5




          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






        • 1




          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 '16 at 6:52






        • 1




          @mchid, consider adding your comment as an answer. It also worked for me on Azure VM.
          – Erik Shilts
          Jan 26 '17 at 22:04














        • 5




          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






        • 1




          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 '16 at 6:52






        • 1




          @mchid, consider adding your comment as an answer. It also worked for me on Azure VM.
          – Erik Shilts
          Jan 26 '17 at 22:04








        5




        5




        this actually worked for me (with the right binary location for echo)
        – orm
        Nov 5 '14 at 19:59




        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




        in OpenVZ not work
        – shilovk
        Mar 3 '15 at 16:03




        1




        1




        alternatively, you could use tee instead: echo 3 | sudo tee /proc/sys/vm/drop_caches
        – mchid
        Dec 23 '15 at 0:09




        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 '16 at 6:52




        Working in an Azure VM. Thanks!
        – lordcheeto
        Feb 9 '16 at 6:52




        1




        1




        @mchid, consider adding your comment as an answer. It also worked for me on Azure VM.
        – Erik Shilts
        Jan 26 '17 at 22:04




        @mchid, consider adding your comment as an answer. It also worked for me on Azure VM.
        – Erik Shilts
        Jan 26 '17 at 22:04










        up vote
        11
        down vote













        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



















        • 1




          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






        • 2




          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








        • 1




          @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















        up vote
        11
        down vote













        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



















        • 1




          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






        • 2




          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








        • 1




          @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













        up vote
        11
        down vote










        up vote
        11
        down vote









        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














        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














        share|improve this answer



        share|improve this answer








        edited Jan 15 '14 at 22:06









        terdon

        127k31245422




        127k31245422










        answered Jan 15 '14 at 20:14









        chaos

        35k773115




        35k773115








        • 1




          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






        • 2




          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








        • 1




          @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














        • 1




          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






        • 2




          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








        • 1




          @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








        1




        1




        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






        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




        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




        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




        2




        2




        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






        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






        1




        1




        @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




        @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










        up vote
        7
        down vote













        You can use echo piped to sudo tee to allow the proper permission needed when you need to echo as root.



        echo 3 | sudo tee /proc/sys/vm/drop_caches


        Use tee --help to list more options.






        share|improve this answer

























          up vote
          7
          down vote













          You can use echo piped to sudo tee to allow the proper permission needed when you need to echo as root.



          echo 3 | sudo tee /proc/sys/vm/drop_caches


          Use tee --help to list more options.






          share|improve this answer























            up vote
            7
            down vote










            up vote
            7
            down vote









            You can use echo piped to sudo tee to allow the proper permission needed when you need to echo as root.



            echo 3 | sudo tee /proc/sys/vm/drop_caches


            Use tee --help to list more options.






            share|improve this answer












            You can use echo piped to sudo tee to allow the proper permission needed when you need to echo as root.



            echo 3 | sudo tee /proc/sys/vm/drop_caches


            Use tee --help to list more options.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 29 '17 at 16:59









            mchid

            8341917




            8341917






















                up vote
                0
                down vote













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



                This command work for me without /usr/bin/echo in mchid answer. It was giving error sh: 1: /usr/bin/echo: not found . So used only 'echo'






                share|improve this answer

























                  up vote
                  0
                  down vote













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



                  This command work for me without /usr/bin/echo in mchid answer. It was giving error sh: 1: /usr/bin/echo: not found . So used only 'echo'






                  share|improve this answer























                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









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



                    This command work for me without /usr/bin/echo in mchid answer. It was giving error sh: 1: /usr/bin/echo: not found . So used only 'echo'






                    share|improve this answer












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



                    This command work for me without /usr/bin/echo in mchid answer. It was giving error sh: 1: /usr/bin/echo: not found . So used only 'echo'







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Oct 16 at 11:47









                    ascii_walker

                    1012




                    1012






















                        up vote
                        0
                        down vote













                        I had the same problem when I tried to use sudo like this:
                        sudo echo 1 > /proc/sys/vm/overcommit_memory



                        My solution was to temporarily switch to root. Obiously, that permission has to be enabled on your system:



                        1. "sudo su -"  #temporarily switch to root user
                        2. echo 1 > /proc/sys/vm/overcommit_memory
                        3. exit # Exit as root.





                        share|improve this answer

























                          up vote
                          0
                          down vote













                          I had the same problem when I tried to use sudo like this:
                          sudo echo 1 > /proc/sys/vm/overcommit_memory



                          My solution was to temporarily switch to root. Obiously, that permission has to be enabled on your system:



                          1. "sudo su -"  #temporarily switch to root user
                          2. echo 1 > /proc/sys/vm/overcommit_memory
                          3. exit # Exit as root.





                          share|improve this answer























                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            I had the same problem when I tried to use sudo like this:
                            sudo echo 1 > /proc/sys/vm/overcommit_memory



                            My solution was to temporarily switch to root. Obiously, that permission has to be enabled on your system:



                            1. "sudo su -"  #temporarily switch to root user
                            2. echo 1 > /proc/sys/vm/overcommit_memory
                            3. exit # Exit as root.





                            share|improve this answer












                            I had the same problem when I tried to use sudo like this:
                            sudo echo 1 > /proc/sys/vm/overcommit_memory



                            My solution was to temporarily switch to root. Obiously, that permission has to be enabled on your system:



                            1. "sudo su -"  #temporarily switch to root user
                            2. echo 1 > /proc/sys/vm/overcommit_memory
                            3. exit # Exit as root.






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Dec 4 at 16:31









                            thebiggestlebowski

                            1011




                            1011






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Unix & Linux Stack Exchange!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.





                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                Please pay close attention to the following guidance:


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f109496%2fecho-3-proc-sys-vm-drop-caches-permission-denied-as-root%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Morgemoulin

                                Scott Moir

                                Souastre