How to change value of /proc/sys/fs/inotify/max_user_watches

I am working with meteor.js and I need to increase the value of /proc/sys/fs/inotify/max_user_watches to solve my problem (here is a description of problem and solution).

But I can not do it:

➜  ~  sudo echo 10000 > /proc/sys/fs/inotify/max_user_watches
zsh: permission denied: /proc/sys/fs/inotify/max_user_watches

How can I change this value ?


Just become root by running

sudo su

And then

echo 10000 > /proc/sys/fs/inotify/max_user_watches

with your command, only the part on the left is run as root. you're running echo as root but not the file writing on the right. You could use this to echo as a normal user and write to the file as root.

echo 10000 | sudo tee /proc/sys/fs/inotify/max_user_watches

tee will write to standard out (your terminal) and to a file, so you run tee as root to write to a root-owned file.


For permanent configuration:

echo 'fs.inotify.max_user_watches = 1524288' | sudo tee /etc/sysctl.d/99-whatever.conf 
sudo sysctl -p --system

then restart the application you've been using.

source: https://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit and this: https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers