Friday, March 6, 2009

Tip: Solving the sudo redirect "problem"

Upon using sudo more frequently I came across an issue while using redirects, for example:
% sudo echo WITHOUT_IPFILTER=yes > /etc/make.conf
root: Permission denied.
The key to solve the "problem" was to run the command in a sub-shell to make the redirection work, like so:
% sudo sh -c 'echo WITHOUT_IPFILTER=yes > /etc/make.conf'
The answer to this lies in man sudo ;)

No comments: