When you run the following statement to clear the cache, reported Permission denied Error: -bash: / proc / sys / vm / drop_caches: Permission denied
sudo echo 1 > /proc/sys/vm/drop_caches
sudo echo 2 > /proc/sys/vm/drop_caches
sudo echo 3 > /proc/sys/vm/drop_caches
sync
bash refuses to do so, suggesting that access is not enough, because the redirection symbol ">" is also the bash. sudo just let the echo command has root privileges,
but did not let the ">" command also have root privileges, so bash would think that this command does not write access to information.
Solution:
"Sh -c" command, which lets bash will be a string of commands to perform as a complete
sudo sh -c "echo 1 > /proc/sys/vm/drop_caches"
sudo sh -c "echo 2 > /proc/sys/vm/drop_caches"
sudo sh -c "echo 3 > /proc/sys/vm/drop_caches"
Or
echo 1 | sudo tee / proc / sys / vm / drop_caches
----------------
Disclaimer: This article is the original article CSDN bloggers "Alexander gyro", and follow CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source and link this statement.
Original link: https: //blog.csdn.net/don_chiang709/article/details/91489003