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

Publish date: 2024-05-08
$ echo 3 > /proc/sys/vm/drop_caches bash: /proc/sys/vm/drop_caches: Permission denied 

Tried with the system password. But still failing.

5

3 Answers

Execute the shell as root:

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

Or redirect the input to a process that will write to file as root:

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

There is another possibility (not mentioned in answers here yet) is when you use a OpenVZ server, where even the "root" user may not be able to change the proc values.

Mine had read only permissions for root, and even though group was root, I couldn't change it with chmod.

For more info, refer to answers here: https://unix.stackexchange.com/questions/109496/echo-3-proc-sys-vm-drop-caches-permission-denied-as-root

You should do it with root user. Or atleast should use sudo then command.

sync; echo 3 > /proc/sys/vm/drop_caches 
0

ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobWlvY26Ac4WOm5isoF2lv7CvjKywrGWmonqlvs6pZJyZk52ytHnPnqmmoaOotrC6jJ2cp6GVmQ%3D%3D