sudo cat foo > barThe "cat foo" portion is executed as root, the "> bar" is executed as the original user. The first option is to execute a shell as the privileged user, and then execute the commands.
sudo -s cat foo > barThe downside of this is that an audit trail of commands executed with privilege is lost. To maintain an audit trail, each command has to be individually executed via sudo. But if both the command and the redirect need to happen as root, it can be done in two manners:
sudo sh -c "cat foo > bar"or
sudo cat foo | tee sudo barI prefer the first method, it will create a single entry in the audit trail and seems more elegant.