3 ms·
A good use case is to redirect output into a file you only can modify with sudo. Trying to do it like this doesn't work: sudo echo "fs.inotify.max_user_watch
by denisw 12y ago
A good use case is to redirect output into a file you only can modify with sudo. Trying to do it like this doesn't work:
sudo echo "fs.inotify.max_user_watches=1000000" > /etc/sysctl.conf
as the redirection happens within the shell, thus without root permissions. However, the following does work:
echo "fs.inotify.max_user_watches=1000000" | sudo tee /etc/sysctl.conf
as the writing is done by the elevated tee process.
- derefr 12y agoThat seems like an anti-unixism (operating with multiple EUIDs in a single process group), though I'm not too sure what the equivalent unixism would be—maybe something with a daemon and a spool directory? Or a user-writable FIFO, redirected to the correct file by the elevated user in a separate command?