-1

When I clear Linux caches, I use this:

echo 3 > /proc/sys/vm/drop_caches

It tells me: Insufficient permissions

Then I inspect the file drop_caches with:

ls -l /proc/sys/vm/drop_caches

and I get this:

-rw-r--r-- 1 root root 0  1月 22 01:21 /proc/sys/vm/drop_caches

So I use:

chmod 777 /proc/sys/vm/drop_caches

to change the file permissions, but insufficient permissions is printed again.

Current user is root, how can I change the permissions of this file?

chrk
  • 4,037
  • 2
  • 39
  • 47
叶同学
  • 801
  • 1
  • 9
  • 21

2 Answers2

0

As root, echo 3 > /proc/sys/vm/drop_caches should work. Run whoami to make sure you are root.

If not, type sudo -i or su to open a root shell where you can run these commands.

ZNix
  • 61
  • 1
  • 3
0

You can't.

Permissions on /proc nodes are defined in the kernel, and cannot be changed at runtime.

  • I am a new one at Linux , could you tell me what should I do ? – 叶同学 Jan 23 '17 at 02:00
  • @Y.yeli What you _should_ do? Don't use drop_caches. The only effect it has is reducing performance until the cache refills. –  Jan 23 '17 at 02:43
  • That's depressed. I run "git pull" just , It prints this: error: cannot fork() for git-remote-https: Cannot allocate memory ,Then I check the memary: total used free shared buffers cached Mem: 256M 132M 123M 8.6M 0B 45M -/+ buffers/cache: 86M 169M Swap: 128M 128M 0B – 叶同学 Jan 23 '17 at 03:18
  • The only thing that I can do is restart the VPS ,right ? – 叶同学 Jan 23 '17 at 03:19
  • 1
    @Y.yeli There is something wrong with your machine. Contact your host. –  Jan 23 '17 at 03:25