Score:0

drop_cache Permissions Denied

ar flag

I was following https://www.tecmint.com/clear-ram-memory-cache-buffer-and-swap-space-on-linux/ and I realized that I had no permissions for /proc/sys/vm/drop_caches. I even used sudo su and it still said Permissions denied. Why can't I access this file? All I want to do is to be able to access it and even with complete root privilages I can't?

Ubuntu 20.04

Doug Smythies avatar
gn flag
Ubuntu version? Kernel version? Example of your terminal commands and results? Permissions for the file? (mine are `--w------- 1 root root 0 Feb 15 17:05 /proc/sys/vm/drop_caches`).
in flag
Some caches and buffers cannot be dropped at will, as that would immediately crash the OS. Could you [edit] your question to explain the reasoning for why you'd like to manually force this process to take place? Perhaps there is a less drastic course of action that you could take
waltinator avatar
it flag
How are you trying to "access" it? The file permissions ("`--w-------`") only allow **w**riting by the owner. The "file" is a pseudo data sink, a way of passing instructions to the kernel.
Doug Smythies avatar
gn flag
@matigo : I disagree. drop_caches will not crash the OS (see the kernel documentation). It might slow it down, temporarily. I have never had an issue with it. I always sync first. My use case is test repeatability, where I need the exact same starting conditions, including cache.
Score:0
gn flag

This is not really an answer, but rather just an example of what we have been asking for in the comments. Notice how the commands just work and 31 gigabytes of cache is dropped:

root@s19:/home/doug/tmp#
root@s19:/home/doug/tmp# free -m
              total        used        free      shared  buff/cache   available
Mem:          31940         386         258           3       31295       31086
Swap:          2047           0        2047
root@s19:/home/doug/tmp# sync
root@s19:/home/doug/tmp# echo 3 > /proc/sys/vm/drop_caches
root@s19:/home/doug/tmp# free -m
              total        used        free      shared  buff/cache   available
Mem:          31940         287       31510           3         142       31314
Swap:          2047           0        2047
root@s19:/home/doug/tmp#

The example was done on physical hardware, but was also tried on a full (KVM/QEMU) virtual computer. I do not know if it works on a VPS or whatever.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.