0

I am trying to clear the cache on my laptop running:

Operating System: Ubuntu 20.04 LTS
          Kernel: Linux 5.4.0-40-generic

However when I put in these commands this is the output:

$ sudo sync; echo 1 > /proc/sys/vm/drop_caches
bash: /proc/sys/vm/drop_caches: Permission denied
$ sudo sync; echo 2 > /proc/sys/vm/drop_caches
bash: /proc/sys/vm/drop_caches: Permission denied
$ sudo sync; echo 3 > /proc/sys/vm/drop_caches
bash: /proc/sys/vm/drop_caches: Permission denied

However when checking my permissions I get this:

$ sudo -l
Matching Defaults entries for [MY USERNAME] on [COMPUTER NAME]:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User [MY USERNAME] may run the following commands on [COMPUTER NAME]:
    (ALL : ALL) ALL

It would appear that I can run all commands. Why is this happening, and is there a fix?

I have also replicated the issue in root.

1
2

You are running sync with sudo, but not the shell's redirection of the echo. Instead do:

sudo sh -c 'sync; echo 1 > /proc/sys/vm/drop_caches'

or

sudo sync; echo 1 | sudo tee /proc/sys/vm/drop_caches >/dev/null
2
  • @KevinWilkins accept that answer if it helped – Gryu Jul 3 '20 at 20:00
  • Thanks for the reminder! – Kevin Wilkins Jul 3 '20 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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