I ran into an interesting problem today. I was trying to increase the maximum number of open file handles allowed by the OS (a server application I was working on wanted lots of file handles available). I tried:
$ sudo echo 2097152 > /proc/sys/fs/file-max
but got “permission denied”. I found this trick to make sure that sudo passes its permissions all the way through the whole operation:
$ sudo sh -c “sudo echo 2097152 > /proc/sys/fs/file-max”
and it worked just fine.