Tuesday, May 12, 2009

Unix redirection with SUDO

Whenever you execute 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).

Example:

$ 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.

Example:

$ sudo sh -c 'echo letter > /etc/papersize'

Readers who read this page, also read:




Bookmark and Share My Zimbio http://www.wikio.com

0 comments: