Redirection with sudo
When performing redirection of a command run with sudo, the redirection will be performed as the user calling sudo, not as the superuser (or user specified with the sudo -u flag).
$ sudo echo letter > /etc/papersize
bash: /etc/papersize: Permission denied
To perform redirection as the superuser (or sudo -u user), place the command in quotes after sh -c.
$ sudo sh -c 'echo letter > /etc/papersize'
Back to brandonhutchinson.com.
Last modified: 2007/05/31